andreska commited on
Commit
c714579
·
verified ·
1 Parent(s): e69518c

Try to pass question and context to AI

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -1,7 +1,21 @@
 
1
  import gradio as gr
 
2
 
3
- def analyze(project_data, question):
4
- return f"Returns: {project_data}\nQuestion: {question}"
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  iface = gr.Interface(
7
  fn=analyze,
 
1
+ import os
2
  import gradio as gr
3
+ from huggingface_hub import InferenceClient
4
 
5
+ def analyze_project(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,