mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-05 19:11:52 +00:00
refactor: The first refactored version for sdk release (#907)
Co-authored-by: chengfangyin2 <chengfangyin3@jd.com>
This commit is contained in:
18
examples/sdk/simple_sdk_llm_example.py
Normal file
18
examples/sdk/simple_sdk_llm_example.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import asyncio
|
||||
from dbgpt.core.awel import DAG
|
||||
from dbgpt.core import BaseOutputParser, OpenAILLM, RequestBuildOperator, PromptTemplate
|
||||
|
||||
with DAG("simple_sdk_llm_example_dag") as dag:
|
||||
prompt = PromptTemplate.from_template(
|
||||
"Write a SQL of {dialect} to query all data of {table_name}."
|
||||
)
|
||||
req_builder = RequestBuildOperator(model="gpt-3.5-turbo")
|
||||
llm = OpenAILLM()
|
||||
out_parser = BaseOutputParser()
|
||||
prompt >> req_builder >> llm >> out_parser
|
||||
|
||||
if __name__ == "__main__":
|
||||
output = asyncio.run(
|
||||
out_parser.call(call_data={"data": {"dialect": "mysql", "table_name": "user"}})
|
||||
)
|
||||
print(f"output: \n\n{output}")
|
Reference in New Issue
Block a user