Skip to content

Commit

Permalink
Merge pull request #24 from neo4j-field/implement-langsmith
Browse files Browse the repository at this point in the history
implement langsmith logging
  • Loading branch information
a-s-g93 authored Mar 4, 2024
2 parents 7b5f5fc + d8a699c commit 7253afe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/app/backend/tools/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import openai
from langchain_community.chat_models import ChatVertexAI, AzureChatOpenAI
from langchain_openai import OpenAI
# from langchain.chains import ConversationChain
import pandas as pd
from pydantic import BaseModel
Expand All @@ -12,6 +13,7 @@
from tools.secret_manager import SecretManager

sm = SecretManager()
os.environ["LANGCHAIN_API_KEY"] = sm.access_secret_version("langsmith_api_key")

class LLM(BaseModel):
"""
Expand Down Expand Up @@ -59,6 +61,9 @@ def _init_llm(self, llm_type: str, temperature: float):
deployment_name = sm.access_secret_version('gpt4_8k_name'),
model_name = 'gpt-4',
temperature=temperature) # default is 0.7
# self.llm_instance = OpenAI(api_key=sm.access_secret_version("openai_key_dan"),
# model="gpt-4",
# temperature=temperature)
case "GPT-4 32k":
# Tokens per Minute Rate Limit (thousands): 30
# Rate limit (Tokens per minute): 30000
Expand All @@ -69,6 +74,9 @@ def _init_llm(self, llm_type: str, temperature: float):
deployment_name = sm.access_secret_version('gpt4_32k_name'),
model_name = 'gpt-4-32k',
temperature=temperature) # default is 0.7
# self.llm_instance = OpenAI(api_key=sm.access_secret_version("openai_key_dan"),
# model="gpt-4-32k",
# temperature=temperature)
case _:
raise ValueError("Please provide a valid LLM type.")

Expand Down
3 changes: 3 additions & 0 deletions src/main/app/dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ RUN pip install -U pip
RUN pip3 install -r requirements.txt

ENV PORT=8080
ENV LANGCHAIN_TRACING_V2="true"
ENV LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"
ENV LANGCHAIN_PROJECT="agent-neo"

# HEALTHCHECK CMD curl --fail http://localhost:8080/_stcore/health
RUN find /usr/local/lib/python3.11/site-packages/streamlit -type f \( -iname \*.py -o -iname \*.js \) -print0 | xargs -0 sed -i 's/healthz/health-check/g'
Expand Down
1 change: 1 addition & 0 deletions src/main/app/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ google-cloud-storage==2.10.0
gcloud==0.18.3
graphdatascience==1.7
langchain==0.0.311
langchain-openai-0.0.8
langcodes==3.3.0
langsmith==0.0.43
neo4j==5.8.0
Expand Down

0 comments on commit 7253afe

Please sign in to comment.