Python integration #8
4 changed files with 37 additions and 29 deletions
|
@ -2,6 +2,7 @@ import requests
|
||||||
import json
|
import json
|
||||||
from transformers import AutoTokenizer, LlamaForCausalLM
|
from transformers import AutoTokenizer, LlamaForCausalLM
|
||||||
|
|
||||||
|
|
||||||
class API:
|
class API:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def process_text_transformers(prompt, model):
|
def process_text_transformers(prompt, model):
|
||||||
|
|
|
@ -1,20 +1,24 @@
|
||||||
from api import API
|
from api import API
|
||||||
|
|
||||||
|
|
||||||
|
class CLIChat:
|
||||||
|
@staticmethod
|
||||||
|
def chat():
|
||||||
chat1 = API()
|
chat1 = API()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
print("")
|
print("")
|
||||||
print("Which AI Model do you want to use? Write as a Number (1-5)")
|
print("Which AI Model do you want to use? Write as a Number (1-5).")
|
||||||
model_input = input()
|
model_input = input()
|
||||||
model = int(model_input)
|
model = int(model_input)
|
||||||
if model <= 0 or model > 5:
|
if model <= 0 or model > 5:
|
||||||
print("ungültiges Modell")
|
print("Invalid model.")
|
||||||
continue
|
continue
|
||||||
while True:
|
while True:
|
||||||
print("")
|
print("")
|
||||||
print("Ask a question")
|
print("Ask a question")
|
||||||
inputText = input ()
|
input_text = input()
|
||||||
if inputText == "change":
|
if input_text == "change":
|
||||||
break
|
break
|
||||||
outputText = chat1.send_message(inputText, model)
|
output_text = chat1.send_message(input_text, model)
|
||||||
print(outputText)
|
print(output_text)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<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>
|
<title>AI Assistant</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
||||||
<!-- Input section: Where user input is provided -->
|
<!-- Input section: Where user input is provided -->
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<input type="text" placeholder="Type your message here..." />
|
<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>
|
<button>Send</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
from flask import Flask
|
from flask import Flask, send_from_directory
|
||||||
|
|
||||||
|
|
||||||
|
class WebHost:
|
||||||
|
@staticmethod
|
||||||
|
def main_page():
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
return app.send_static_file('index.html')
|
return app.send_static_file('index.html')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run()
|
app.run(debug=True)
|
||||||
|
|
Loading…
Reference in a new issue