-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #841 from Undertone0809/v1.18.0/optimize-streamlit…
…-chatbot feat: add streamlit sidebar component in beta
- Loading branch information
Showing
9 changed files
with
146 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from promptulate.beta import agents, rag | ||
from promptulate.beta import agents, rag, st | ||
|
||
__all__ = ["agents", "rag"] | ||
__all__ = ["agents", "rag", "st"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from promptulate.beta.st.sidebar import model_sidebar | ||
|
||
__all__ = ["model_sidebar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from typing import List, TypedDict | ||
|
||
|
||
class ModelConfig(TypedDict): | ||
model_name: str | ||
api_key: str | ||
api_base: str | ||
|
||
|
||
def model_sidebar(model_options: List[str] = None) -> ModelConfig: | ||
import streamlit as st | ||
|
||
model_options = model_options or [ | ||
"Custom Model", | ||
"openai/gpt-4o", | ||
"openai/gpt-4o-mini", | ||
"openai/gpt-4-turbo", | ||
"deepseek/deepseek-chat", | ||
"claude-3-5-sonnet-20240620", | ||
"zhipu/glm-4", | ||
"ollama/llama2", | ||
"groq/llama-3.1-70b-versatile", | ||
] | ||
|
||
with st.sidebar: | ||
selected_model = st.selectbox("Language Model Name", model_options) | ||
|
||
if selected_model == "Custom Model": | ||
selected_model = st.text_input( | ||
"Enter Custom Model Name", | ||
placeholder="Custom model name, eg: groq/llama3-70b-8192", | ||
help="For more details, please see [how to write model name?](https://www.promptulate.cn/#/other/how_to_write_model_name)", # noqa | ||
) | ||
|
||
api_key = st.text_input("API Key", key="provider_api_key", type="password") | ||
api_base = st.text_input("OpenAI Proxy URL (Optional)") | ||
|
||
return ModelConfig(model_name=selected_model, api_key=api_key, api_base=api_base) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters