shoom013 commited on
Commit
1a274eb
·
verified ·
1 Parent(s): 2d56a6a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -12,6 +12,8 @@ from llama_index.core import (
12
  Document,
13
  Settings,
14
  )
 
 
15
  from llama_index.llms.huggingface import (HuggingFaceLLM, )
16
  from llama_index.llms.huggingface_api import (HuggingFaceInferenceAPI, )
17
  from llama_index.core.base.llms.types import ChatMessage
@@ -118,7 +120,7 @@ def resetChat():
118
  print("Restarted!!!")
119
  return True
120
 
121
- def rag(input_text, history, jezik): # , file):
122
  global sp_flag
123
  # if (btn):
124
  # resetChat()
@@ -192,13 +194,16 @@ def rag(input_text, history, jezik): # , file):
192
  # if (o_jezik!='N/A'):
193
  # input_text += " - odgovori " + o_jezik + "."
194
  # Settings.llm.system_prompt = system_prompt
195
-
196
  response = chat_engine.chat(str({"role": "user", "content": system_prompt + input_text})).response
197
  # response = query_engine.query(input_text)
 
 
 
198
  return response
199
  # gr.Textbox(label="Pitanje:", lines=6),
200
  # outputs=[gr.Textbox(label="Odgovor:", lines=6)],
201
  # ChatMessage(role="assistant", content="Kako Vam mogu pomoći?")
 
202
  with gr.Blocks() as iface:
203
  ichat = gr.ChatInterface(fn=rag,
204
  title="UChat",
 
12
  Document,
13
  Settings,
14
  )
15
+ import requests
16
+ import json
17
  from llama_index.llms.huggingface import (HuggingFaceLLM, )
18
  from llama_index.llms.huggingface_api import (HuggingFaceInferenceAPI, )
19
  from llama_index.core.base.llms.types import ChatMessage
 
120
  print("Restarted!!!")
121
  return True
122
 
123
+ def rag(input_text, history, jezik, request: gr.Request): # , file):
124
  global sp_flag
125
  # if (btn):
126
  # resetChat()
 
194
  # if (o_jezik!='N/A'):
195
  # input_text += " - odgovori " + o_jezik + "."
196
  # Settings.llm.system_prompt = system_prompt
 
197
  response = chat_engine.chat(str({"role": "user", "content": system_prompt + input_text})).response
198
  # response = query_engine.query(input_text)
199
+ session_hash = request.session_hash
200
+ url = "https://houseofplaying.com/ufo/list.php?limit=1" # An example public API
201
+ response = requests.get(url)
202
  return response
203
  # gr.Textbox(label="Pitanje:", lines=6),
204
  # outputs=[gr.Textbox(label="Odgovor:", lines=6)],
205
  # ChatMessage(role="assistant", content="Kako Vam mogu pomoći?")
206
+
207
  with gr.Blocks() as iface:
208
  ichat = gr.ChatInterface(fn=rag,
209
  title="UChat",