Add shields

This commit is contained in:
William Fu-Hinthorn
2024-03-20 22:03:42 -07:00
parent 1b2ab09745
commit 97bced99b4
3 changed files with 15 additions and 3 deletions
+9 -1
View File
@@ -1,4 +1,10 @@
# Tweet Critic
# Online Prompt Optimization
<!-- markdown-link-check-disable -->
[![GitHub](https://img.shields.io/badge/GitHub-Repository-blue?style=for-the-badge&logo=github)](https://github.com/langchain-ai/tweet-critic)
[![Streamlit App](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](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.
![Demo](./img/demo.gif)
## Getting Started
To run the application locally, follow these steps:
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 MiB

+6 -2
View File
@@ -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()