| from gradio_client import Client | |
| import os | |
| # This will be the URL of DeepV's Gradio App | |
| GRADIO_APP_URL = "FICS-LLM/DeepV" # Replace with your actual app URL | |
| try: | |
| # Initialize the Gradio client | |
| client = Client(GRADIO_APP_URL) | |
| print("DeepV Gradio client initialized successfully!") | |
| # input design spec to prompt LLM | |
| design_spec = "Create me a 2x1 multiplexer with the following module header: module mux2x1(input wire a, input wire b, input wire sel, output wire y);" | |
| # number of retrieved documents for RAG | |
| k_value = 1 | |
| # Set if you would like to use DeepV's RAG technique | |
| rag_enabled = True | |
| # Select your model: gpt-4o, gpt-4.1, gpt-5-chat-latest | |
| model_name = "gpt-4o" | |
| openai_key = "" # Replace with your actual OpenAI API key | |
| # Note: Your OpenAI API key is only active for this session and is not saved or stored. | |
| # Customize some generation parameters (temperature, top_p, max_tokens) | |
| temp_value = 0.5 | |
| top_p_value = 0.9 | |
| max_tokens = 1024 | |
| # --- Call the Gradio app's API endpoint --- | |
| # The `predict` method corresponds to a component's action. | |
| response = client.predict( | |
| design_spec, | |
| rag_enabled, | |
| k_value, | |
| model_name, | |
| openai_key, | |
| temp_value, | |
| top_p_value, | |
| max_tokens, | |
| api_name="/run_generation" # Assuming 'run_generation' is exposed as an API | |
| ) | |
| # --- Process the response --- | |
| generated_code = response[0] | |
| print("\n--- API Call Successful! ---") | |
| print("\nGenerated Verilog Code:") | |
| print("-------------------------") | |
| print(generated_code) | |
| except Exception as e: | |
| print(f"An error occurred: {e}") | |
| print("Please ensure your Gradio app is running and the URL is correct.") | |
| print("You might also need to find the correct `fn_index` if the API call fails.") | |