Skip to content

Commit

Permalink
feat: add workflow for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
csunny committed Dec 27, 2024
1 parent 78c0368 commit bbf0431
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 8 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/run_examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Run Examples

on:
push:
branches:
- fix_examples
pull_request:
branches:
- fix_examples

jobs:
run-examples:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m venv venv
source venv/bin/activate
pip install -e ".[default]"
- name: Run Examples
run: |
source venv/bin/activate
python -m examples
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPEN_API_BASE: ${{ secrets.OPENAI_API_BASE }}

9 changes: 5 additions & 4 deletions dbgpt/rag/embedding/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,9 +803,10 @@ def embed_query(self, text: str) -> List[float]:
"Please install ollama by command `pip install ollama"
) from e
try:
return (
Client(self.api_url).embeddings(model=self.model_name, prompt=text)
)["embedding"]
embedding = Client(self.api_url).embeddings(
model=self.model_name, prompt=text
)
return list(embedding["embedding"])
except ollama.ResponseError as e:
raise ValueError(f"**Ollama Response Error, Please CheckErrorInfo.**: {e}")

Expand Down Expand Up @@ -839,7 +840,7 @@ async def aembed_query(self, text: str) -> List[float]:
embedding = await AsyncClient(host=self.api_url).embeddings(
model=self.model_name, prompt=text
)
return embedding["embedding"]
return list(embedding["embedding"])
except ollama.ResponseError as e:
raise ValueError(f"**Ollama Response Error, Please CheckErrorInfo.**: {e}")

Expand Down
3 changes: 3 additions & 0 deletions examples/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TODO add example run code here
if __name__ == "__main__":
print("hello world!")
6 changes: 2 additions & 4 deletions examples/agents/auto_plan_agent_dialogue_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"""

import asyncio
import os

from dbgpt.agent import (
AgentContext,
Expand All @@ -36,10 +35,9 @@ async def main():
from dbgpt.model.proxy import OpenAILLMClient

agent_memory = AgentMemory()
from dbgpt.model.proxy.llms.tongyi import TongyiLLMClient

llm_client = TongyiLLMClient(
model_alias="qwen2-72b-instruct",
llm_client = OpenAILLMClient(
model_alias="gpt-4o",
)

context: AgentContext = AgentContext(
Expand Down

0 comments on commit bbf0431

Please sign in to comment.