File size: 1,861 Bytes
1316d52 cf7ca46 1316d52 e9bd7f5 1316d52 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 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.")
|