MarcoAland commited on
Commit
e396b54
·
verified ·
1 Parent(s): 00fb704

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -21
app.py CHANGED
@@ -6,28 +6,28 @@ from RAGModule import RAGModule
6
  # Initialize the RAG module
7
  RAG_Triwira = RAGModule()
8
 
9
- # def chat(message: str, chat_history: str):
10
- # prompt = RAG_Triwira.main(message)
11
- # url = "http://localhost:11434/api/generate"
12
- # payload = json.dumps({
13
- # "model": "MarcoAland/llama3.1-rag-indo",
14
- # "prompt": prompt,
15
- # "format": "json",
16
- # "stream": False
17
- # })
18
- # headers = {
19
- # 'Content-Type': 'application/json'
20
- # }
21
 
22
- # try:
23
- # response = requests.post(url, headers=headers, data=payload)
24
- # response.raise_for_status() # Raise an error for bad status codes
25
- # response_data = response.json()
26
- # return response_data.get('output', 'No response received')
27
- # except requests.exceptions.RequestException as e:
28
- # return f"Connection error: {e}"
29
- def chat(message, chat_history):
30
- yield "test"
31
  # Define the Gradio interface
32
  iface = gr.Interface(
33
  fn=chat,
 
6
  # Initialize the RAG module
7
  RAG_Triwira = RAGModule()
8
 
9
+ def chat(message: str, chat_history: str):
10
+ prompt = RAG_Triwira.main(message)
11
+ url = "http://localhost:11434/api/generate"
12
+ payload = json.dumps({
13
+ "model": "ollama:latest", #"MarcoAland/llama3.1-rag-indo",
14
+ "prompt": prompt,
15
+ "format": "json",
16
+ "stream": False
17
+ })
18
+ headers = {
19
+ 'Content-Type': 'application/json'
20
+ }
21
 
22
+ try:
23
+ response = requests.post(url, headers=headers, data=payload)
24
+ response.raise_for_status() # Raise an error for bad status codes
25
+ response_data = response.json()
26
+ return response_data.get('output', 'No response received')
27
+ except requests.exceptions.RequestException as e:
28
+ return f"Connection error: {e}"
29
+ # def chat(message, chat_history):
30
+ # yield "test"
31
  # Define the Gradio interface
32
  iface = gr.Interface(
33
  fn=chat,