-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from Fundacio-i2CAT/10-integration-of-ollama-l…
…lm-container Add ollama container for LLM capabilities and enhanced employee profiling
- Loading branch information
Showing
16 changed files
with
243 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from ollama import Client | ||
from infohound_project.settings import OLLAMA_URL,OLLAMA_MODEL | ||
|
||
def check_or_pull_model(client): | ||
models = client.list() | ||
present = False | ||
for model in models["models"]: | ||
if OLLAMA_MODEL == model["name"].split(":")[0]: | ||
present = True | ||
if not present: | ||
client.pull(OLLAMA_MODEL) | ||
|
||
def ollama_flexible_prompt(in_prompt): | ||
client = Client(host=OLLAMA_URL) | ||
check_or_pull_model(client) | ||
desc = None | ||
try: | ||
res = client.generate(model=OLLAMA_MODEL,prompt=in_prompt) | ||
except Exception as e: | ||
print(f"Could not call Ollama instance: {e}") | ||
|
||
if "response" in res: | ||
desc = res["response"].strip() | ||
return desc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import time | ||
from infohound.models import People | ||
from infohound.tool.ai_assistant import ollama | ||
|
||
def summarize_profile(domain_id): | ||
queryset = People.objects.filter(domain_id=domain_id, ocupation_summary__contains="This profile doesn't have a description yet") | ||
|
||
for entry in queryset.iterator(): | ||
try: | ||
summarize_prompt = "Summarize the ocupation of the person in just 150 words given the following data: " | ||
raw_data = entry.raw_metadata | ||
print ("Executing AI-Powered Profile Analisis of: " + entry.name) | ||
entry.ocupation_summary = ollama.ollama_flexible_prompt(summarize_prompt + raw_data) | ||
print ("Summary: " +entry.ocupation_summary) | ||
entry.save() | ||
except Exception as e: | ||
print(f"Error inesperado: {str(e)}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.