-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
39 lines (29 loc) · 1.01 KB
/
Copy pathtest.py
File metadata and controls
39 lines (29 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from __future__ import annotations
from pathlib import Path
import sys
from dotenv import load_dotenv
ROOT = Path(__file__).resolve().parent
SRC = ROOT / "src"
if str(SRC) not in sys.path:
sys.path.insert(0, str(SRC))
from doubao_pipeline.client import DoubaoClient # noqa: E402
from doubao_pipeline.config import load_api_config # noqa: E402
def main() -> None:
load_dotenv(dotenv_path=ROOT / ".env")
config = load_api_config()
client = DoubaoClient(config)
response = client.ask(
question="请联网回答:你是什么模型,并附上可引用来源",
enable_web_search=True,
force_web_search_prompt=True,
)
print("answer:")
print(response.answer_text)
print("---")
print(f"web_search_called={response.web_search_called}")
print(f"search_queries={response.search_queries}")
print(f"citations={response.citations}")
print(f"latency_ms={response.latency_ms}")
print(f"token_total={response.token_total}")
if __name__ == "__main__":
main()