mirror of
https://github.com/langchain-ai/tweet-critic.git
synced 2026-07-01 13:20:26 -04:00
Add shields
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
# Tweet Critic
|
||||
# Online Prompt Optimization
|
||||
|
||||
<!-- markdown-link-check-disable -->
|
||||
[](https://github.com/langchain-ai/tweet-critic)
|
||||
|
||||
[](https://tweet-critic.streamlit.app/)
|
||||
<!-- markdown-link-check-enable -->
|
||||
|
||||
Welcome to the tweet critic prompt optimization demo! This repository showcases a Streamlit application that demonstrates how to iteratively refine and optimize prompts based on user feedback and dialog.
|
||||
|
||||
@@ -9,6 +15,8 @@ It employs a two common optimization techniques:
|
||||
- Few-shot Learning: approved examples (those given a 👍) are added to a LangSmith few-shot prompt dataset and later dynamically injected in the chat bot's system prompt.
|
||||
- Prompt Optimization: When a 👍 or 👎 is provided, an "optimizer" prompt is used to propose updates to the chat bot to help it better satisfy this type of user request in the future. These updates are checked in the the [LangSmith Hub](https://smith.langchain.com/hub) so you can see the updates and roll back prompts if desired.
|
||||
|
||||

|
||||
|
||||
## Getting Started
|
||||
|
||||
To run the application locally, follow these steps:
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.7 MiB |
@@ -33,8 +33,6 @@ OPTIMIZER_PROMPT_NAME = "wfh/convo-optimizer"
|
||||
NUM_FEWSHOTS = 15
|
||||
PROMPT_UPDATE_BATCHSIZE = 5
|
||||
|
||||
chat_llm = ChatAnthropic(model="claude-3-haiku-20240307", temperature=1)
|
||||
optimizer_llm = ChatAnthropic(model="claude-3-opus-20240229", temperature=1)
|
||||
|
||||
# Add a sidebar
|
||||
st.sidebar.title("Session Information")
|
||||
@@ -56,6 +54,12 @@ st.sidebar.markdown(f"[See Prompt in Hub]({prompt_url})")
|
||||
optimizer_prompt_url = f"https://smith.langchain.com/hub/{OPTIMIZER_PROMPT_NAME}"
|
||||
st.sidebar.markdown(f"[See Optimizer Prompt in Hub]({optimizer_prompt_url})")
|
||||
|
||||
chat_llm_model = st.sidebar.selectbox("Chat LLM Model", ["haiku", "opus"])
|
||||
if chat_llm_model == "haiku":
|
||||
chat_llm = ChatAnthropic(model=f"claude-3-{chat_llm_model}-20240307", temperature=1)
|
||||
else:
|
||||
chat_llm = ChatAnthropic(model=f"claude-3-{chat_llm_model}-20240229", temperature=1)
|
||||
optimizer_llm = ChatAnthropic(model="claude-3-opus-20240229", temperature=1)
|
||||
## Get few-shot examples from 👍 examples
|
||||
client = Client()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user