Spaces:
Runtime error
Runtime error
Try update to work with AI query, and add more debug output if still failing
Browse files
app.py
CHANGED
|
@@ -3,20 +3,30 @@ import gradio as gr
|
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
def analyze(project_data, question):
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
inputs=
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
iface = gr.Interface(
|
| 21 |
fn=analyze,
|
| 22 |
inputs=[
|
|
|
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
def analyze(project_data, question):
|
| 6 |
+
try:
|
| 7 |
+
api_key = os.getenv("HF_API_KEY")
|
| 8 |
+
client = InferenceClient(
|
| 9 |
+
model="Qwen/Qwen2.5-72B-Instruct",
|
| 10 |
+
token=api_key
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
prompt = f"Analyze this project: {project_data}\n\nQuestion: {question}"
|
| 14 |
+
inputs = client.encoding("text", prompt)
|
| 15 |
+
|
| 16 |
+
response = client.text_generation(
|
| 17 |
+
prompt,
|
| 18 |
+
max_new_tokens=512,
|
| 19 |
+
temperature=0.7,
|
| 20 |
+
top_p=0.95,
|
| 21 |
+
repetition_penalty=1.1,
|
| 22 |
+
do_sample=True
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
return outputs["generated_text"][0]
|
| 26 |
+
except Exception as e:
|
| 27 |
+
print(f"Error details: {str(e)}")
|
| 28 |
+
return f"Error occurred: {str(e)}"
|
| 29 |
+
|
| 30 |
iface = gr.Interface(
|
| 31 |
fn=analyze,
|
| 32 |
inputs=[
|