main #3

Merged
sageTheDm merged 3 commits from React-Group/ai-virtual-assistant:main into main 2024-09-16 11:56:00 +02:00
7 changed files with 52 additions and 5 deletions
Showing only changes of commit c4655fb49e - Show all commits

3
py/.idea/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View file

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

7
py/.idea/misc.xml Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.12" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12" project-jdk-type="Python SDK" />
</project>

8
py/.idea/modules.xml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/py.iml" filepath="$PROJECT_DIR$/.idea/py.iml" />
</modules>
</component>
</project>

8
py/.idea/py.iml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
py/.idea/vcs.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

View file

@ -2,10 +2,10 @@ import requests
import json import json
class api: class API:
def initialize_ollama(self, prompt): @staticmethod
def process_text(prompt, model):
ollama_url = "http://localhost:11434" ollama_url = "http://localhost:11434"
model = "phi3.5"
response = requests.post( response = requests.post(
f"{ollama_url}/api/generate", json={"model": model, "prompt": prompt} f"{ollama_url}/api/generate", json={"model": model, "prompt": prompt}
@ -24,6 +24,15 @@ class api:
else: else:
return "Error: " + response.text return "Error: " + response.text
def send_message(self, message): def send_message(self, message, model):
answer = self.initialize_ollama(message) if model == 1:
answer = self.process_text(message, "phi3.5")
elif model == 2:
answer = self.process_text(message, "gemma2:2b")
elif model == 3:
answer = self.process_text(message, "qwen2:0.5b")
elif model == 4:
answer = self.process_text(message, "codegemma:2b")
else:
return "Invalid choice"
return answer return answer