macadeliccc commited on
Commit
ef2a575
1 Parent(s): ba9f5b4
Files changed (1) hide show
  1. app.py +20 -1
app.py CHANGED
@@ -46,11 +46,30 @@ def chat_with_ochat(message):
46
  except requests.RequestException as e:
47
  return f"Error: {e}"
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  # Chat history variable
50
  chat_history = []
51
 
52
  # Create a Gradio Blocks interface
53
- with gr.Blocks() as app:
54
  gr.Markdown("## vLLM OpenChat-3.5 Interface")
55
  gr.Markdown("Type your message and get a response from the ochat server.")
56
  with gr.Row():
 
46
  except requests.RequestException as e:
47
  return f"Error: {e}"
48
 
49
+
50
+ def code_chat(message, condition="Code"):
51
+ url = "http://localhost:18888/v1/chat/completions"
52
+ headers = {"Content-Type": "application/json"}
53
+ data = {
54
+ "model": "openchat_3.5",
55
+ "condition": condition,
56
+ "messages": [{"role": "user", "content": message}]
57
+ }
58
+
59
+ try:
60
+ response = requests.post(url, json=data, headers=headers)
61
+ if response.status_code == 200:
62
+ return response.json()
63
+ else:
64
+ return f"Error: Server responded with status code {response.status_code}"
65
+ except requests.RequestException as e:
66
+ return f"Error: {e}"
67
+
68
  # Chat history variable
69
  chat_history = []
70
 
71
  # Create a Gradio Blocks interface
72
+ with gr.Blocks(theme=gr.themes.Soft()) as app:
73
  gr.Markdown("## vLLM OpenChat-3.5 Interface")
74
  gr.Markdown("Type your message and get a response from the ochat server.")
75
  with gr.Row():