Dooratre commited on
Commit
22eeeb1
·
verified ·
1 Parent(s): 1b21f37

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import requests
2
  from flask import Flask, render_template, request
3
- import speech_recognition as sr
4
 
5
  app = Flask(__name__)
6
  with open('i.txt', 'r') as file:
@@ -8,7 +8,6 @@ with open('i.txt', 'r') as file:
8
  API_URL = "https://api-inference.huggingface.co/models/mistralai/Mixtral-8x7B-Instruct-v0.1"
9
  headers = {"Authorization": f"Bearer hf{data}"}
10
 
11
- recognizer = sr.Recognizer()
12
 
13
  def query(payload):
14
  response = requests.post(API_URL, headers=headers, json=payload)
@@ -18,7 +17,7 @@ conversation_history = []
18
 
19
  def generate_response(user_input):
20
  new_query = {
21
- "inputs": f"you are ai for help in anything you are created by Mr,Omar Nuwara he is made you \n\n make sure to help people in anything \n\ntask:complete the reesponse:\n\nconversation history:{conversation_history}\n\nuser message:{user_input}\n\nmake sure to response about it and don't generate alot of words just based on the user message \n\n\n\nresponse:",
22
  "parameters": {
23
  "top_k": 50,
24
  "top_p": 0.9,
@@ -57,7 +56,7 @@ def generate_response(user_input):
57
 
58
  @app.route('/')
59
  def index():
60
- return render_template('index.html')
61
 
62
  @app.route('/chat', methods=['POST'])
63
  def chat():
@@ -65,7 +64,7 @@ def chat():
65
 
66
  # Generate AI response based on user input
67
  response_text = generate_response(user_input)
68
- conversation_history.append({"User": user_input, "AI": response_text})
69
 
70
  return response_text
71
 
 
1
  import requests
2
  from flask import Flask, render_template, request
3
+
4
 
5
  app = Flask(__name__)
6
  with open('i.txt', 'r') as file:
 
8
  API_URL = "https://api-inference.huggingface.co/models/mistralai/Mixtral-8x7B-Instruct-v0.1"
9
  headers = {"Authorization": f"Bearer hf{data}"}
10
 
 
11
 
12
  def query(payload):
13
  response = requests.post(API_URL, headers=headers, json=payload)
 
17
 
18
  def generate_response(user_input):
19
  new_query = {
20
+ "inputs": f"you are ai created by Mr,Omar Nuwara he is made you \n\n start chat with omar and ask him or answer him you are free with him \n\ntask:complete the reesponse:\n\nconversation history:{conversation_history}\n\nomar message:{user_input}\n\nmake sure to response about it and don't generate alot of words just based on the user message \n\n\n\nresponse:",
21
  "parameters": {
22
  "top_k": 50,
23
  "top_p": 0.9,
 
56
 
57
  @app.route('/')
58
  def index():
59
+ return render_template('cont.html',data=data)
60
 
61
  @app.route('/chat', methods=['POST'])
62
  def chat():
 
64
 
65
  # Generate AI response based on user input
66
  response_text = generate_response(user_input)
67
+ conversation_history.append({"omar": user_input, "AI": response_text})
68
 
69
  return response_text
70