mirror of
https://github.com/tiennm99/ai-coding-workflow-labs.git
synced 2026-09-16 16:24:03 +00:00
feat: init
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
.idea
|
||||
|
||||
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
from haystack_integrations.components.generators.ollama import OllamaGenerator
|
||||
|
||||
from haystack import Pipeline, Document
|
||||
from haystack.components.retrievers.in_memory import InMemoryBM25Retriever
|
||||
from haystack.components.builders.prompt_builder import PromptBuilder
|
||||
from haystack.document_stores.in_memory import InMemoryDocumentStore
|
||||
|
||||
# Write documents to InMemoryDocumentStore
|
||||
document_store = InMemoryDocumentStore()
|
||||
document_store.write_documents([
|
||||
Document(content="My name is Jean and I live in Paris."),
|
||||
Document(content="My name is Mark and I live in Berlin."),
|
||||
Document(content="My name is Giorgio and I live in Rome.")
|
||||
])
|
||||
|
||||
# Build a RAG pipeline
|
||||
prompt_template = """
|
||||
Given these documents, answer the question.
|
||||
Documents:
|
||||
{% for doc in documents %}
|
||||
{{ doc.content }}
|
||||
{% endfor %}
|
||||
Question: {{question}}
|
||||
Answer:
|
||||
"""
|
||||
|
||||
retriever = InMemoryBM25Retriever(document_store=document_store)
|
||||
prompt_builder = PromptBuilder(template=prompt_template)
|
||||
llm = OllamaGenerator(url = "http://localhost:11434", model="llama3.2:1b")
|
||||
|
||||
rag_pipeline = Pipeline()
|
||||
rag_pipeline.add_component("retriever", retriever)
|
||||
rag_pipeline.add_component("prompt_builder", prompt_builder)
|
||||
rag_pipeline.add_component("llm", llm)
|
||||
rag_pipeline.connect("retriever", "prompt_builder.documents")
|
||||
rag_pipeline.connect("prompt_builder", "llm")
|
||||
|
||||
# Ask a question
|
||||
question = "Who lives in Paris?"
|
||||
results = rag_pipeline.run(
|
||||
{
|
||||
"retriever": {"query": question},
|
||||
"prompt_builder": {"question": question},
|
||||
}
|
||||
)
|
||||
|
||||
print(results["llm"]["replies"])
|
||||
@@ -0,0 +1,55 @@
|
||||
aiohappyeyeballs==2.4.6
|
||||
aiohttp==3.11.13
|
||||
aiosignal==1.3.2
|
||||
annotated-types==0.7.0
|
||||
anyio==4.8.0
|
||||
async-timeout==5.0.1
|
||||
attrs==25.1.0
|
||||
backoff==2.2.1
|
||||
certifi==2025.1.31
|
||||
charset-normalizer==3.4.1
|
||||
colorama==0.4.6
|
||||
distro==1.9.0
|
||||
exceptiongroup==1.2.2
|
||||
frozenlist==1.5.0
|
||||
h11==0.14.0
|
||||
haystack-ai==2.10.3
|
||||
haystack-experimental==0.7.0
|
||||
httpcore==1.0.7
|
||||
httpx==0.28.1
|
||||
idna==3.10
|
||||
Jinja2==3.1.5
|
||||
jiter==0.8.2
|
||||
jsonref==1.1.0
|
||||
jsonschema==4.23.0
|
||||
jsonschema-specifications==2024.10.1
|
||||
lazy_imports==0.4.0
|
||||
MarkupSafe==3.0.2
|
||||
monotonic==1.6
|
||||
more-itertools==10.6.0
|
||||
multidict==6.1.0
|
||||
networkx==3.4.2
|
||||
numpy==2.2.3
|
||||
ollama==0.4.7
|
||||
ollama-haystack==2.3.0
|
||||
openai==1.65.2
|
||||
openapi-llm==0.4.1
|
||||
pandas==2.2.3
|
||||
posthog==3.11.0
|
||||
propcache==0.3.0
|
||||
pydantic==2.10.6
|
||||
pydantic_core==2.27.2
|
||||
python-dateutil==2.9.0.post0
|
||||
pytz==2025.1
|
||||
PyYAML==6.0.2
|
||||
referencing==0.36.2
|
||||
requests==2.32.3
|
||||
rpds-py==0.23.1
|
||||
six==1.17.0
|
||||
sniffio==1.3.1
|
||||
tenacity==9.0.0
|
||||
tqdm==4.67.1
|
||||
typing_extensions==4.12.2
|
||||
tzdata==2025.1
|
||||
urllib3==2.3.0
|
||||
yarl==1.18.3
|
||||
Reference in New Issue
Block a user