Python integration #8

Merged
sageTheDm merged 2 commits from React-Group/ai-virtual-assistant:main into main 2024-09-16 13:45:39 +02:00
4 changed files with 37 additions and 29 deletions

View file

@ -2,6 +2,7 @@ import requests
import json
from transformers import AutoTokenizer, LlamaForCausalLM
class API:
@staticmethod
def process_text_transformers(prompt, model):
@ -46,4 +47,4 @@ class API:
answer = self.process_text_transformers(message, "meta-llama/Meta-Llama-3.1-8B")
else:
return "Invalid choice"
return answer
return answer

View file

@ -1,20 +1,24 @@
from api import API
chat1 = API()
while True:
print("")
print("Which AI Model do you want to use? Write as a Number (1-5)")
model_input = input()
model = int(model_input)
if model <=0 or model > 5:
print("ungültiges Modell")
continue
while True:
print("")
print("Ask a question")
inputText = input ()
if inputText == "change":
break
outputText = chat1.send_message(inputText, model)
print(outputText)
class CLIChat:
@staticmethod
def chat():
chat1 = API()
while True:
print("")
print("Which AI Model do you want to use? Write as a Number (1-5).")
model_input = input()
model = int(model_input)
if model <= 0 or model > 5:
print("Invalid model.")
continue
while True:
print("")
print("Ask a question")
input_text = input()
if input_text == "change":
break
output_text = chat1.send_message(input_text, model)
print(output_text)

View file

@ -4,7 +4,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="/static/styles.css">
<title>AI Assistant</title>
</head>
@ -81,10 +81,10 @@
<!-- Input section: Where user input is provided -->
<div class="input">
<input type="text" placeholder="Type your message here..." />
<button><img src="img/microphone.svg" alt="microphone"></button>
<button><img src="/static/img/microphone.svg" alt="microphone"></button>
<button>Send</button>
</div>
</div>
</body>
</html>
</html>

View file

@ -1,11 +1,14 @@
from flask import Flask
app = Flask(__name__)
from flask import Flask, send_from_directory
@app.route('/')
def index():
return app.send_static_file('index.html')
class WebHost:
@staticmethod
def main_page():
app = Flask(__name__)
if __name__ == '__main__':
app.run()
@app.route('/')
def index():
return app.send_static_file('index.html')
if __name__ == '__main__':
app.run(debug=True)