themissingCRAM commited on
Commit
5992538
·
1 Parent(s): ee14926
Files changed (1) hide show
  1. app.py +1 -53
app.py CHANGED
@@ -12,6 +12,7 @@ client = InferenceClient(
12
  )
13
 
14
 
 
15
  def sql_engine(query: str) -> str:
16
  """
17
  Allows you to perform SQL queries on the table. Returns a string representation of the result.
@@ -33,59 +34,6 @@ def sql_engine(query: str) -> str:
33
  return output
34
 
35
 
36
- def respond(
37
- message,
38
- history: list[tuple[str, str]],
39
- system_message,
40
- max_tokens,
41
- temperature,
42
- top_p,
43
- ):
44
- messages = [{"role": "system", "content": system_message}]
45
-
46
- for val in history:
47
- if val[0]:
48
- messages.append({"role": "user", "content": val[0]})
49
- if val[1]:
50
- messages.append({"role": "assistant", "content": val[1]})
51
-
52
- messages.append({"role": "user", "content": message})
53
-
54
- response = ""
55
-
56
- # agent.run("Can you give me the name of the client who got the most expensive receipt?")
57
-
58
- for message in agent.chat_completion(
59
- messages,
60
- max_tokens=max_tokens,
61
- stream=True,
62
- temperature=temperature,
63
- top_p=top_p,
64
- ):
65
- token = message.choices[0].delta.content
66
-
67
- response += token
68
- yield response
69
-
70
-
71
- """
72
- For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
73
- """
74
- demo = gr.ChatInterface(
75
- respond,
76
- additional_inputs=[
77
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
78
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
79
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
80
- gr.Slider(
81
- minimum=0.1,
82
- maximum=1.0,
83
- value=0.95,
84
- step=0.05,
85
- label="Top-p (nucleus sampling)",
86
- ),
87
- ],
88
- )
89
  if __name__ == "__main__":
90
  agent = CodeAgent(
91
  tools=[sql_engine],
 
12
  )
13
 
14
 
15
+ @tool
16
  def sql_engine(query: str) -> str:
17
  """
18
  Allows you to perform SQL queries on the table. Returns a string representation of the result.
 
34
  return output
35
 
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  if __name__ == "__main__":
38
  agent = CodeAgent(
39
  tools=[sql_engine],