ChatGPT 4o 部分
ChatGPT 4o API 示例
from openai import OpenAI
model_use = "gpt-4o-2024-08-06"
client = OpenAI(api_key="Your-API-key")
completion = client.beta.chat.completions.parse(
model=model_use,
messages=[
{"role": "system", "content": "Extract the event information."},
{"role": "user", "content": "Alice and Bob are going to a science fair on Friday."},
],
)
event = completion.choices[0].message.parsed
注意:我尝试使用模型 “gpt-4o” 但未成功。
如何创建 ChatGPT API Key
- 登录 openai
- 使用搜索栏搜索 “API keys”
- 创建一个新的密钥(仅显示一次,关闭标签页后不可见)
- 前往账单页面为账户充值
UniTox ChatGPT 部分
从 fda.gov 读取数据
-
从 .csv 文件中读取我们感兴趣的药物标签。
-
读取页面上的 .html 文件或 .pdf 文件。
-
通过 ChatGPT 对 .html 和 .pdf 文件生成摘要。
-
利用 ChatGPT 生成的摘要,让 ChatGPT 判断该药物是否具有毒性,以及毒性程度。
Initial Prompt: Provide a summary of all the parts of the drug label that discuss cardiotoxicity risks and cardiotoxic reactions for this drug. In your summary of each sentence, clearly state whether the drug itself was associated with or caused the cardiotoxicity risk. Output1 Toxidity Score Prompt: Given the above information about a drug, answer 'was this drug associated with No Cardiotoxicity, Less Cardiotoxicity, or Most Cardiotoxicity?' Now, answer with just one word: No, Less or Most. Output1 (Summary) OUtput2 Toxidity Test Prompt: Given the above information about a drug, answer 'was this drug associated with Cardiotoxicity?' Now, answer with just one word: Yes or No. Output1 Output3 <-> compare GT

Llama 部分
Ollama 部分
首先在服务器上启动一个 ollama 服务:
ml ollama # activate ollama
ollama serve # open ollama server
在 Python 中使用 ollama 的示例:
pip install ollama
from ollama import chat, Client, ChatResponse
client = Client(host='http://localhost:11434')
model_use = "llama3.2"
completion = client.chat(
model=model_use,
messages=[
{"role": "system", "content": "Extract the event information."},
{"role": "user", "content": "Alice and Bob are going to a science fair on Friday."},
],
)
completion['message']['content']