Skip to content

Commit

Permalink
Evaluation plus minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
felipearosr committed Feb 14, 2024
1 parent d40bfdc commit 16999e8
Show file tree
Hide file tree
Showing 26 changed files with 805 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
5.Sources\ Extended
7.HybridRetriever
6.HybridRetrievercopy
8.Prompting
8.Token counter
9.Cohere Reranker
*.files
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 12 additions & 14 deletions 6.HybridRetriever/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@
import openai
import chainlit as cl

from llama_index import ServiceContext, VectorStoreIndex #, OpenAIEmbedding
from llama_index import OpenAIEmbedding
from pinecone import Pinecone
from llama_index import (
ServiceContext,
VectorStoreIndex,
set_global_service_context,
OpenAIEmbedding,
)
from llama_index.llms import OpenAI
from llama_index.text_splitter import SentenceSplitter
from llama_index.vector_stores import PineconeVectorStore
from llama_index.callbacks.base import CallbackManager
from pinecone import Pinecone
from llama_index import set_global_service_context

openai.api_key = os.environ.get("OPENAI_API_KEY")
pinecone_api_key = os.environ.get("PINECONE_API_KEY")

MODEL = "gpt-4-0125-preview" # "gpt-3.5-turbo" - "gpt-4-0125-preview" - "gpt-3.5-turbo-0125" - OLD "gpt-3.5-turbo"
EMBEDDING = "text-embedding-3-large" # "text-embedding-3-small" - OLD "text-embedding-ada-002"
MODEL = "gpt-4-0125-preview"
EMBEDDING = "text-embedding-3-large"


@cl.cache
def load_context():
Expand All @@ -25,11 +28,8 @@ def load_context():
pinecone_index=pinecone_index,
)
service_context = ServiceContext.from_defaults(
llm=OpenAI(
temperature=0.1, model=MODEL, max_tokens=3072, streaming=True
),
llm=OpenAI(temperature=0.1, model=MODEL, max_tokens=3072, streaming=True),
embed_model=OpenAIEmbedding(model=EMBEDDING),
text_splitter=SentenceSplitter(chunk_size=1024, chunk_overlap=126),
callback_manager=CallbackManager([cl.LlamaIndexCallbackHandler()]),
)
set_global_service_context(service_context)
Expand Down Expand Up @@ -82,9 +82,7 @@ async def main(message: cl.Message):

message_history.append({"author": "Human", "content": user_message})
message_history.append({"author": "AI", "content": response_message.content})
message_history = message_history[
-6:
] # This keeps only the last 3 pairs of messages
message_history = message_history[-6:]
cl.user_session.set("message_history", message_history)

label_list = []
Expand Down
84 changes: 84 additions & 0 deletions 8.Evaluation with TruLens/.chainlit/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
[project]
# Whether to enable telemetry (default: true). No personal data is collected.
enable_telemetry = true

# List of environment variables to be provided by each user to use the app.
user_env = []

# Duration (in seconds) during which the session is saved when the connection is lost
session_timeout = 3600

# Enable third parties caching (e.g LangChain cache)
cache = false

# Follow symlink for asset mount (see https://github.com/Chainlit/chainlit/issues/317)
# follow_symlink = false

[features]
# Show the prompt playground
prompt_playground = true

# Process and display HTML in messages. This can be a security risk (see https://stackoverflow.com/questions/19603097/why-is-it-dangerous-to-render-user-generated-html-or-javascript)
unsafe_allow_html = false

# Process and display mathematical expressions. This can clash with "$" characters in messages.
latex = false

# Authorize users to upload files with messages
multi_modal = false

# Allows user to use speech to text
[features.speech_to_text]
enabled = false
# See all languages here https://github.com/JamesBrill/react-speech-recognition/blob/HEAD/docs/API.md#language-string
# language = "en-US"

[UI]
# Name of the app and chatbot.
name = "Chatbot"

# Show the readme while the thread is empty.
show_readme_as_default = false

# Description of the app and chatbot. This is used for HTML tags.
# description = ""

# Large size content are by default collapsed for a cleaner ui
default_collapse_content = true

# The default value for the expand messages settings.
default_expand_messages = false

# Hide the chain of thought details from the user in the UI.
hide_cot = false

# Link to your github repo. This will add a github button in the UI's header.
# github = ""

# Specify a CSS file that can be used to customize the user interface.
# The CSS file can be served from the public directory or via an external link.
# custom_css = "/public/test.css"

# Override default MUI light theme. (Check theme.ts)
[UI.theme.light]
#background = "#FAFAFA"
#paper = "#FFFFFF"

[UI.theme.light.primary]
#main = "#F80061"
#dark = "#980039"
#light = "#FFE7EB"

# Override default MUI dark theme. (Check theme.ts)
[UI.theme.dark]
#background = "#FAFAFA"
#paper = "#FFFFFF"

[UI.theme.dark.primary]
#main = "#F80061"
#dark = "#980039"
#light = "#FFE7EB"


[meta]
generated_by = "1.0.101"
155 changes: 155 additions & 0 deletions 8.Evaluation with TruLens/.chainlit/translations/en-US.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
{
"components": {
"atoms": {
"buttons": {
"userButton": {
"menu": {
"settings": "Settings",
"settingsKey": "S",
"APIKeys": "API Keys",
"logout": "Logout"
}
}
}
},
"molecules": {
"newChatButton": {
"newChat": "New Chat"
},
"tasklist": {
"TaskList": {
"title": "\ud83d\uddd2\ufe0f Task List",
"loading": "Loading...",
"error": "An error occured"
}
},
"attachments": {
"cancelUpload": "Cancel upload",
"removeAttachment": "Remove attachment"
},
"newChatDialog": {
"createNewChat": "Create new chat?",
"clearChat": "This will clear the current messages and start a new chat.",
"cancel": "Cancel",
"confirm": "Confirm"
},
"settingsModal": {
"expandMessages": "Expand Messages",
"hideChainOfThought": "Hide Chain of Thought",
"darkMode": "Dark Mode"
}
},
"organisms": {
"chat": {
"history": {
"index": {
"lastInputs": "Last Inputs",
"noInputs": "Such empty...",
"loading": "Loading..."
}
},
"inputBox": {
"input": {
"placeholder": "Type your message here..."
},
"speechButton": {
"start": "Start recording",
"stop": "Stop recording"
},
"SubmitButton": {
"sendMessage": "Send message",
"stopTask": "Stop Task"
},
"UploadButton": {
"attachFiles": "Attach files"
},
"waterMark": {
"text": "Built with"
}
},
"Messages": {
"index": {
"running": "Running",
"executedSuccessfully": "executed successfully",
"failed": "failed",
"feedbackUpdated": "Feedback updated",
"updating": "Updating"
}
},
"dropScreen": {
"dropYourFilesHere": "Drop your files here"
},
"index": {
"failedToUpload": "Failed to upload",
"cancelledUploadOf": "Cancelled upload of",
"couldNotReachServer": "Could not reach the server",
"continuingChat": "Continuing previous chat"
},
"settings": {
"settingsPanel": "Settings panel",
"reset": "Reset",
"cancel": "Cancel",
"confirm": "Confirm"
}
},
"threadHistory": {
"sidebar": {
"filters": {
"FeedbackSelect": {
"feedbackAll": "Feedback: All",
"feedbackPositive": "Feedback: Positive",
"feedbackNegative": "Feedback: Negative"
},
"SearchBar": {
"search": "Search"
}
},
"DeleteThreadButton": {
"confirmMessage": "This will delete the thread as well as it's messages and elements.",
"cancel": "Cancel",
"confirm": "Confirm",
"deletingChat": "Deleting chat",
"chatDeleted": "Chat deleted"
},
"index": {
"pastChats": "Past Chats"
},
"ThreadList": {
"empty": "Empty..."
},
"TriggerButton": {
"closeSidebar": "Close sidebar",
"openSidebar": "Open sidebar"
}
},
"Thread": {
"backToChat": "Go back to chat",
"chatCreatedOn": "This chat was created on"
}
},
"header": {
"chat": "Chat",
"readme": "Readme"
}
}
},
"hooks": {
"useLLMProviders": {
"failedToFetchProviders": "Failed to fetch providers:"
}
},
"pages": {
"Design": {},
"Env": {
"savedSuccessfully": "Saved successfully",
"requiredApiKeys": "Required API Keys",
"requiredApiKeysInfo": "To use this app, the following API keys are required. The keys are stored on your device's local storage."
},
"Page": {
"notPartOfProject": "You are not part of this project."
},
"ResumeButton": {
"resumeChat": "Resume Chat"
}
}
}
Loading

0 comments on commit 16999e8

Please sign in to comment.