Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding support for gemini on linux/wsl distros #79

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ celerybeat.pid
*.sage.py

# Environments
examples/pipelines/demo-question-answering/.env
**/.env
.venv
env/
Expand Down
1 change: 1 addition & 0 deletions examples/pipelines/demo-question-answering/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GEMINI_API_KEY=YOUR_GEMINI_API_KEY
27 changes: 12 additions & 15 deletions examples/pipelines/demo-question-answering/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import logging
import sys

import os
import click
import pathway as pw
import yaml
from dotenv import load_dotenv

from pathway.udfs import DiskCache, ExponentialBackoffRetryStrategy
from pathway.xpacks.llm import embedders, llms, parsers, splitters
from pathway.xpacks.llm.question_answering import BaseRAGQuestionAnswerer
Expand All @@ -23,7 +24,6 @@

load_dotenv()


def data_sources(source_configs) -> list[pw.Table]:
sources = []
for source_config in source_configs:
Expand Down Expand Up @@ -55,27 +55,25 @@ def data_sources(source_configs) -> list[pw.Table]:

return sources


@click.command()
@click.option("--config_file", default="config.yaml", help="Config file to be used.")
def run(
config_file: str = "config.yaml",
):
def run(config_file: str = "config.yaml"):
with open(config_file) as config_f:
configuration = yaml.safe_load(config_f)

GPT_MODEL = configuration["llm_config"]["model"]
LLM_MODEL = configuration["llm_config"]["model"]

embedder = embedders.OpenAIEmbedder(
model="text-embedding-ada-002",
cache_strategy=DiskCache(),
embedding_model = "avsolatorio/GIST-small-Embedding-v0"

embedder = embedders.SentenceTransformerEmbedder(
embedding_model,
call_kwargs={"show_progress_bar": False}
)

chat = llms.OpenAIChat(
model=GPT_MODEL,
chat = llms.LiteLLMChat(
model=LLM_MODEL,
retry_strategy=ExponentialBackoffRetryStrategy(max_retries=6),
cache_strategy=DiskCache(),
temperature=0.05,
)

host_config = configuration["host_config"]
Expand All @@ -94,6 +92,5 @@ def run(

rag_app.run_server(with_cache=True, terminate_on_error=False)


if __name__ == "__main__":
run()
run()
2 changes: 1 addition & 1 deletion examples/pipelines/demo-question-answering/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
llm_config:
model: "gpt-3.5-turbo"
model: "gemini/gemini-pro"
host_config:
host: "0.0.0.0"
port: 8000
Expand Down
3 changes: 3 additions & 0 deletions examples/pipelines/demo-question-answering/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
pathway[all]>=0.11.0
python-dotenv==1.0.1
mpmath==1.3.0
litellm>=1.35
Google-generativeai
Sentence-transformers