JuanMa360 commited on
Commit
42f970b
·
1 Parent(s): fcd4711

bugfix: params

Browse files
Files changed (1) hide show
  1. app.py +6 -34
app.py CHANGED
@@ -1,38 +1,10 @@
 
1
  import gradio as gr
2
- import requests
3
- import json
4
 
5
- def respond(message, property_id: str = "a0de88a24c4e844d86f285d6abbd59d0"):
6
-
7
- try:
8
- url = "https://data-monopolio.dev.dd360.mx/ai-assistant/v1"
9
 
10
- payload = json.dumps({
11
- "query": "cuantos cuartos tiene la propiedad?",
12
- "sessionId": "12345",
13
- "numMessages": 4,
14
- "userId": "user-01",
15
- "property_id": "a0de88a24c4e844d86f285d6abbd59d0"
16
- })
17
- headers = {
18
- 'Content-Type': 'application/json'
19
- }
20
-
21
- response = requests.request("POST", url, headers=headers, data=payload)
22
-
23
-
24
- return response.text
25
- except requests.RequestException as e:
26
- return f"Error: {str(e)}"
27
-
28
- demo = gr.Interface(
29
- fn=respond,
30
- inputs=[
31
- gr.Textbox(label="Message", placeholder="Type your message here..."),
32
- gr.Textbox(label="Property ID", placeholder="Provide property id...")
33
- ],
34
- outputs="text",
35
- )
36
-
37
- if __name__ == "__main__":
38
  demo.launch()
 
1
+ import time
2
  import gradio as gr
 
 
3
 
4
+ def slow_echo(message, history):
5
+ for i in range(len(message)):
6
+ time.sleep(0.3)
7
+ yield "You typed: " + message[: i+1]
8
 
9
+ gr.ChatInterface(slow_echo).launch()in__":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  demo.launch()