fschwartzer commited on
Commit
82871f4
·
verified ·
1 Parent(s): 723fe48

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -1,5 +1,10 @@
1
  import pandas as pd
2
  import gradio as gr
 
 
 
 
 
3
 
4
  # Initial data
5
  data = {
@@ -17,7 +22,7 @@ def add_feedback(name, feedback):
17
  return df
18
 
19
  # Function to get a response from GPT (placeholder for actual GPT call)
20
- def get_gpt_response(question):
21
  # Convert DataFrame to CSV string
22
  csv_data = df.to_csv(index=False)
23
  # Create context with feedback
@@ -25,12 +30,11 @@ def get_gpt_response(question):
25
  Here is the data of people including their names, ages, cities they live in, and feedback:
26
 
27
  {csv_data}
28
-
29
- Question: {question}
30
  """
31
- # Placeholder for GPT call
32
- response = "Charlie, 35 years old, from Chicago is the oldest person."
33
- return response
34
 
35
  def ask_question(question):
36
  response = get_gpt_response(question)
 
1
  import pandas as pd
2
  import gradio as gr
3
+ from transformers import AutoTokenizer, AutoModelForCausalLM
4
+
5
+ model_name = " meta-llama/Llama-2-7b"
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+ model = AutoModelForCausalLM.from_pretrained(model_name)
8
 
9
  # Initial data
10
  data = {
 
22
  return df
23
 
24
  # Function to get a response from GPT (placeholder for actual GPT call)
25
+ def get_gpt_response(query):
26
  # Convert DataFrame to CSV string
27
  csv_data = df.to_csv(index=False)
28
  # Create context with feedback
 
30
  Here is the data of people including their names, ages, cities they live in, and feedback:
31
 
32
  {csv_data}
33
+
 
34
  """
35
+ input_ids = tokenizer(query, return_tensors="pt").input_ids
36
+ output = model.generate(input_ids, max_new_tokens=100)
37
+ return tokenizer.decode(output[0], skip_special_tokens=True)
38
 
39
  def ask_question(question):
40
  response = get_gpt_response(question)