Spaces:
Sleeping
Sleeping
itsalissonsilva
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -21,8 +21,13 @@ def query_nvidia_api(input_text):
|
|
21 |
|
22 |
# Check the response status
|
23 |
if response.status_code == 200:
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
26 |
else:
|
27 |
# Handle errors or unsuccessful responses
|
28 |
return f"Error: {response.text}"
|
@@ -30,7 +35,7 @@ def query_nvidia_api(input_text):
|
|
30 |
# Create the Gradio interface
|
31 |
interface = gr.Interface(fn=query_nvidia_api,
|
32 |
inputs=gr.Textbox(lines=7, placeholder="Enter your text here..."),
|
33 |
-
outputs=
|
34 |
|
35 |
# Launch the app
|
36 |
if __name__ == "__main__":
|
|
|
21 |
|
22 |
# Check the response status
|
23 |
if response.status_code == 200:
|
24 |
+
response_data = response.json()
|
25 |
+
# Assuming the structure is as you provided and extracting the 'content' field
|
26 |
+
if 'choices' in response_data and len(response_data['choices']) > 0:
|
27 |
+
content = response_data['choices'][0].get('message', {}).get('content', '')
|
28 |
+
return content
|
29 |
+
else:
|
30 |
+
return "No content found in response"
|
31 |
else:
|
32 |
# Handle errors or unsuccessful responses
|
33 |
return f"Error: {response.text}"
|
|
|
35 |
# Create the Gradio interface
|
36 |
interface = gr.Interface(fn=query_nvidia_api,
|
37 |
inputs=gr.Textbox(lines=7, placeholder="Enter your text here..."),
|
38 |
+
outputs="text")
|
39 |
|
40 |
# Launch the app
|
41 |
if __name__ == "__main__":
|