Skip to content

Commit

Permalink
fix: config allows overriding LLM
Browse files Browse the repository at this point in the history
  • Loading branch information
andy blair committed Oct 17, 2024
1 parent ad06c22 commit c94c1ab
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
21 changes: 21 additions & 0 deletions examples/high_level/highlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,27 @@ def custom_openai_llm():
continue
print(client.query(prompt, include_own=True))

def custom_llama_llm():
"""
You're not restricted to any LLM provider, you are free to use any of the supported BaseChatModel
(https://python.langchain.com/docs/integrations/chat/)
In this example we're using groq to run Llama 3.1 70b, but this can also be ran on your own hardware
for a totally private RAG!
"""
# pip install langchain-groq
from langchain_groq import ChatGroq

llm = ChatGroq(model="llama3-groq-70b-8192-tool-use-preview")
config = NyxConfigExtended.from_env(provider=ConfigType.BASE)

client = NyxLangChain(config=config, llm=llm)
while True:
prompt = input("What is your question? ")
if prompt == "":
continue
print(client.query(prompt, include_own=True))


if __name__ == "__main__":
custom_openai_llm()
2 changes: 0 additions & 2 deletions nyx_client/nyx_client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,5 @@ def from_env(
api_key = os.environ["OPENAI_API_KEY"]
case ConfigType.COHERE:
api_key = os.environ["COHERE_API_KEY"]
case other:
raise Exception(f"{other} is not a config type")
base = BaseNyxConfig.from_env(env_file, override_token)
return NyxConfigExtended(api_key=api_key, provider=provider, base_config=base)
3 changes: 3 additions & 0 deletions nyx_extras/nyx_extras/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

"""Module that contains utility functions, as well as tooling for manual parsing of data contained in Nyx."""

import json
import logging
import os
import sqlite3
Expand Down Expand Up @@ -191,6 +192,8 @@ def data_as_db(
log.warning("%s is unsupported type %s", d.title, d.content_type)
continue
content.columns = Parser.normalise_values(content.columns)
for col in content.select_dtypes(include=["object"]).columns:
content[col] = content[col].apply(lambda x: json.dumps(x) if isinstance(x, (list, dict)) else x)
content.to_sql(table_name, db_engine)
except pd.errors.ParserError:
if d.content_type in ["csv", "json", *Parser._excel_mimes]:
Expand Down

0 comments on commit c94c1ab

Please sign in to comment.