Expanded AI API.
This commit is contained in:
		
							parent
							
								
									7cdcc35a2a
								
							
						
					
					
						commit
						c4655fb49e
					
				
					 7 changed files with 52 additions and 5 deletions
				
			
		
							
								
								
									
										3
									
								
								py/.idea/.gitignore
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								py/.idea/.gitignore
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,3 @@ | ||||||
|  | # Default ignored files | ||||||
|  | /shelf/ | ||||||
|  | /workspace.xml | ||||||
							
								
								
									
										6
									
								
								py/.idea/inspectionProfiles/profiles_settings.xml
									
										
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								py/.idea/inspectionProfiles/profiles_settings.xml
									
										
									
										generated
									
									
									
										Normal 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
									
										
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								py/.idea/misc.xml
									
										
									
										generated
									
									
									
										Normal 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
									
										
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								py/.idea/modules.xml
									
										
									
										generated
									
									
									
										Normal 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
									
										
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								py/.idea/py.iml
									
										
									
										generated
									
									
									
										Normal 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
									
										
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								py/.idea/vcs.xml
									
										
									
										generated
									
									
									
										Normal 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> | ||||||
							
								
								
									
										19
									
								
								py/api.py
									
										
									
									
									
								
							
							
						
						
									
										19
									
								
								py/api.py
									
										
									
									
									
								
							|  | @ -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 | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Patrick_Pluto
						Patrick_Pluto