Spaces:
Runtime error
Runtime error
Try fix syntax error and improve usability
Browse files
app.py
CHANGED
|
@@ -12,7 +12,7 @@ def analyze(project_data, question):
|
|
| 12 |
|
| 13 |
prompt = f"Analyze this project: {project_data}\n\nQuestion: {question}"
|
| 14 |
|
| 15 |
-
|
| 16 |
prompt,
|
| 17 |
max_new_tokens=512,
|
| 18 |
temperature=0.7,
|
|
@@ -21,25 +21,24 @@ def analyze(project_data, question):
|
|
| 21 |
do_sample=True,
|
| 22 |
stream=True
|
| 23 |
)
|
| 24 |
-
|
| 25 |
-
#return response
|
| 26 |
response_text = ""
|
| 27 |
for token in response_generator:
|
| 28 |
response_text += token.text
|
| 29 |
-
|
| 30 |
|
| 31 |
except Exception as e:
|
| 32 |
print(f"Error details: {str(e)}")
|
| 33 |
-
|
| 34 |
|
| 35 |
iface = gr.Interface(
|
| 36 |
fn=analyze,
|
| 37 |
inputs=[
|
| 38 |
-
gr.Textbox(label="Project Data"),
|
| 39 |
-
gr.Textbox(label="Question")
|
| 40 |
],
|
| 41 |
-
|
| 42 |
-
|
| 43 |
)
|
| 44 |
|
| 45 |
# Configure for external access
|
|
|
|
| 12 |
|
| 13 |
prompt = f"Analyze this project: {project_data}\n\nQuestion: {question}"
|
| 14 |
|
| 15 |
+
response_generator = client.text_generation(
|
| 16 |
prompt,
|
| 17 |
max_new_tokens=512,
|
| 18 |
temperature=0.7,
|
|
|
|
| 21 |
do_sample=True,
|
| 22 |
stream=True
|
| 23 |
)
|
| 24 |
+
|
|
|
|
| 25 |
response_text = ""
|
| 26 |
for token in response_generator:
|
| 27 |
response_text += token.text
|
| 28 |
+
yield response_text
|
| 29 |
|
| 30 |
except Exception as e:
|
| 31 |
print(f"Error details: {str(e)}")
|
| 32 |
+
yield f"Error occurred: {str(e)}"
|
| 33 |
|
| 34 |
iface = gr.Interface(
|
| 35 |
fn=analyze,
|
| 36 |
inputs=[
|
| 37 |
+
gr.Textbox(label="Project Data", lines=2),
|
| 38 |
+
gr.Textbox(label="Question", lines=1)
|
| 39 |
],
|
| 40 |
+
outputs=gr.Textbox(label="Analysis", lines=10, streaming=True),
|
| 41 |
+
api_name="analyze"
|
| 42 |
)
|
| 43 |
|
| 44 |
# Configure for external access
|