andreska commited on
Commit
4f47f17
·
verified ·
1 Parent(s): acac196

Try update to work with AI query, and add more debug output if still failing

Browse files
Files changed (1) hide show
  1. app.py +24 -14
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
- api_key = os.getenv("HF_API_KEY")
7
- client = InferenceClient(api_key=api_key)
8
-
9
- prompt = f"Analyze this project: {project_data}\n\nQuestion: {question}"
10
- inputs = client.encoding("text", prompt)
11
-
12
- outputs = client.generate(
13
- model="Qwen/Qwen2.5-72B-Instruct",
14
- inputs=inputs,
15
- max_new_tokens=100
16
- )
17
-
18
- return outputs["generated_text"][0]
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=[