working on ingestion
This commit is contained in:
parent
1a77b84921
commit
51488b3ee6
|
|
@ -14,6 +14,7 @@ services:
|
|||
LANGFUSE_PUBLIC_KEY: ${LANGFUSE_PUBLIC_KEY}
|
||||
LANGFUSE_SECRET_KEY: ${LANGFUSE_SECRET_KEY}
|
||||
ELASTICSEARCH_INDEX: ${ELASTICSEARCH_INDEX}
|
||||
OLLAMA_MODEL_NAME: ${OLLAMA_MODEL_NAME}
|
||||
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
|
|
|
|||
|
|
@ -19,14 +19,14 @@ class BrunixEngine(brunix_pb2_grpc.AssistanceEngineServicer):
|
|||
def __init__(self):
|
||||
|
||||
self.base_url = os.getenv("LLM_BASE_URL", "http://ollama-light-service:11434")
|
||||
self.model_name = os.getenv("LLM_MODEL", "qwen2.5:1.5b")
|
||||
self.model_name = os.getenv("OLLAMA_MODEL_NAME")
|
||||
|
||||
logger.info(f"Starting server")
|
||||
|
||||
self.llm = Ollama(base_url=self.base_url, model=self.model_name)
|
||||
|
||||
self.embeddings = OllamaEmbeddings(
|
||||
base_url=self.base_url, model="qwen3-embedding:0.6b"
|
||||
base_url=self.base_url, model=self.model_name
|
||||
)
|
||||
|
||||
es_url = os.getenv("ELASTICSEARCH_URL", "http://elasticsearch:9200")
|
||||
|
|
@ -40,7 +40,7 @@ class BrunixEngine(brunix_pb2_grpc.AssistanceEngineServicer):
|
|||
vector_query_field="embedding",
|
||||
)
|
||||
|
||||
def format_context(docs) -> str:
|
||||
def format_context(self, docs) -> str:
|
||||
parts = []
|
||||
for i, d in enumerate(docs, start=1):
|
||||
meta = d.metadata or {}
|
||||
|
|
@ -76,11 +76,9 @@ class BrunixEngine(brunix_pb2_grpc.AssistanceEngineServicer):
|
|||
|
||||
chain = prompt | self.llm
|
||||
|
||||
for chunk in chain.stream(
|
||||
{"context": context_text, "question": request.query}
|
||||
):
|
||||
result = chain.invoke({"context": context_text, "question": request.query})
|
||||
yield brunix_pb2.AgentResponse(
|
||||
text=str(chunk), avap_code="AVAP-2026", is_final=False
|
||||
text=str(result), avap_code="AVAP-2026", is_final=True
|
||||
)
|
||||
|
||||
yield brunix_pb2.AgentResponse(text="", avap_code="", is_final=True)
|
||||
|
|
|
|||
7
Makefile
7
Makefile
|
|
@ -20,3 +20,10 @@ compose_up:
|
|||
sleep 2
|
||||
docker compose -f Docker/docker-compose.yaml --env-file .env up -d --build
|
||||
@echo "✓ Done!"
|
||||
|
||||
# Kill all kubectl port-forward tunnels
|
||||
.PHONY: tunnels_down
|
||||
tunnels_down:
|
||||
@echo "Killing all kubectl port-forward tunnels..."
|
||||
-pkill -f 'kubectl port-forward' || true
|
||||
@echo "✓ All tunnels killed!"
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,153 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "9949107c",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'http://host.docker.internal:11434'"
|
||||
]
|
||||
},
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from langchain_community.embeddings import OllamaEmbeddings\n",
|
||||
"import os\n",
|
||||
"from langchain_community.llms import Ollama\n",
|
||||
"\n",
|
||||
"os.getenv(\"LLM_BASE_URL\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"id": "458fd5c2",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"embeddings = OllamaEmbeddings(\n",
|
||||
" base_url=\"http://localhost:11434\", model=\"qwen2.5:1.5b\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"id": "679cbf21",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"v = embeddings.embed_documents([\"hello world\", \"goodbye world\"])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"id": "ee9afd0c",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"list"
|
||||
]
|
||||
},
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"type(v)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"id": "5f85dc6f",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"1536"
|
||||
]
|
||||
},
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"len(v[0])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"id": "1e8b8ecd",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/tmp/ipykernel_34744/3454453355.py:1: LangChainDeprecationWarning: The class `Ollama` was deprecated in LangChain 0.3.1 and will be removed in 1.0.0. An updated version of the class exists in the `langchain-ollama package and should be used instead. To use it run `pip install -U `langchain-ollama` and import as `from `langchain_ollama import OllamaLLM``.\n",
|
||||
" llm = Ollama(base_url=\"http://localhost:11434\", model=\"qwen2.5:1.5b\")\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"llm = Ollama(base_url=\"http://localhost:11434\", model=\"qwen2.5:1.5b\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "1db5f6e3",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Princilandia does not actually exist as a country or city on Earth. The term \"Princilandia\" appears to be made up or fictional and doesn't correspond to any real geographical location with an official capital.\n",
|
||||
"\n",
|
||||
"The correct answer would depend on which imaginary world you're referring to, but without that context, I can't provide the specific name of the capital for Princilandia. If you're interested in information about a country known as \"Princelandia\" or have another question about such places, please feel free to ask and I'd be happy to help!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"response = llm.invoke(\"\")\n",
|
||||
"print(response)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "assistance-engine",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.11"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
Loading…
Reference in New Issue