Docfile commited on
Commit
0b97ff9
·
1 Parent(s): d2b13eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -46
app.py CHANGED
@@ -8,56 +8,49 @@ from langchain_g4f import G4FLLM
8
  g4f.debug.logging = True # Enable logging
9
  g4f.check_version = False # Disable automatic version checking
10
  #print(g4f.version) # Check version
11
- print(g4f.Provider.Ails.params) # Supported args
12
 
13
 
14
- url = "https://app.embedchain.ai/api/v1/pipelines/f14b3df8-db63-456c-8a7f-4323b4467271/context/"
15
 
 
16
 
17
 
18
  def greet(name):
19
- payload = {
20
  "query": f"{name}",
21
- "count": 15
22
- }
23
- headers = {
24
- 'Authorization': 'Token ec-pbVFWamfNAciPwb18ZwaQkKKUCCBnafko9ydl3Y5',
25
- }
26
-
27
-
28
- response = requests.request("POST", url, headers=headers, json=payload)
29
-
30
- print(name)
31
- c = response.text
32
-
33
-
34
- llm = LLM = G4FLLM(model=models.gpt_35_turbo_16k)
35
-
36
-
37
- def hein(q):
38
- re = llm(q)
39
- return re
40
-
41
-
42
- with gr.Blocks() as demo:
43
- chatbot = gr.Chatbot()
44
- msg = gr.Textbox()
45
- clear = gr.ClearButton([msg, chatbot])
46
-
47
- def respond(message, chat_history):
48
- print(message)
49
- print("ok")
50
- print(chat_history)
51
- res = hein(q)
52
- bot_message = res
53
- chat_history.append((message,bot_message))
54
- time.sleep(2)
55
- return "", chat_history
56
-
57
- msg.submit(respond, [msg, chatbot], [msg, chatbot])
58
-
59
- demo.launch()
60
-
61
-
62
- #iface = gr.Interface(fn=greet, inputs="text", outputs="text")
63
- #iface.launch()
 
8
  g4f.debug.logging = True # Enable logging
9
  g4f.check_version = False # Disable automatic version checking
10
  #print(g4f.version) # Check version
11
+ #print(g4f.Provider.Ails.params) # Supported args
12
 
13
 
 
14
 
15
+ url = "https://app.embedchain.ai/api/v1/pipelines/024a60fa-cfc3-41a2-a27b-2f6a04c1a6fe/context/"
16
 
17
 
18
  def greet(name):
19
+ payload = {
20
  "query": f"{name}",
21
+ "count": 25 }
22
+ headers = {
23
+ 'Authorization': 'Token ec-fBwP02l3yodIa40BHkSEdhqVQmelK8pNsbrUew2J',}
24
+ response = requests.request("POST", url, headers=headers, json=payload)
25
+
26
+ print(response.text)
27
+ print(name)
28
+ c = response.text
29
+ llm = LLM = G4FLLM(model=models.gpt_35_turbo_16k )
30
+ res = llm(f"""
31
+ Use the following pieces of context to answer the query at the end.
32
+ If you don't know the answer, just say that you don't know, don't try to make up an answer.
33
+
34
+ ${c}
35
+
36
+ Query: ${name}
37
+
38
+ Helpful Answer:
39
+ system_prompt: |
40
+ Agis en tant qu'assistant juridique gabonais Répons au question en français et en citant les articles .
41
+
42
+ """)
43
+ print(res)
44
+ return res
45
+
46
+
47
+
48
+ iface = gr.Interface(
49
+ fn=greet,
50
+ inputs="text",
51
+ outputs=gr.Textbox(label="Réponse"),
52
+ title="bot",
53
+ description=" Chatbot-law-code-pénal ")
54
+
55
+ iface.launch()
56
+