亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

? ??? ?? ??? ???? LangChain? Python? ??? ?? AI? ?? ???? ??? ??? - 3

LangChain? Python? ??? ?? AI? ?? ???? ??? ??? - 3

Dec 30, 2024 am 01:11 AM

Comprehensive Beginner

?????? AI? ???? ???? ???? ????? ???? ???, ???, ?? ?? ?? ??? ???? ??? ? ????. LangChain? ???? ??, ???? ??, ??? ? ?? ??? ?? ?? ?? ???? ?? Generative AI ?? ??? ????? ????????.

? ?????? LangChain ? Python? ???? Generative AI? ???? ? ??? ?? ??? ??? ?????.


1. ????? ??????

LangChain? OpenAI? GPT ?? Hugging Face ??? ?? ??? ?? ??(LLM)? ???? ??????? ???? ?? Python ?? ????????. ??? ???:

  • ???? ??: ??? ???? ???? ????? ????.
  • ?? ????: ?? LLM ??? ?? ????? ?????.
  • ?? ??: AI ??? API, ?????? ?? ????? ? ??? ???.
  • ??? ??: ??? ?? ????? ????? ?????.

2. ?? ??

a) ?? ????? ??

????? LangChain ? ?? ?????? ?????.

pip install langchain openai python-dotenv streamlit

b) OpenAI API ? ??

  1. OpenAI ??? ???? API ?? ????: OpenAI API.
  2. ???? ????? .env ??? ???? API ?? ?????.
   OPENAI_API_KEY=your_api_key_here
  1. dotenv? ???? Python ????? API ?? ?????.
   from dotenv import load_dotenv
   import os

   load_dotenv()
   openai_api_key = os.getenv("OPENAI_API_KEY")

3. LangChain? ?? ??

a) ????

AI? ??? ??? ????? ???? ???????. LangChain? ???? PromptTemplate? ???? ????? ????? ??? ? ????.

from langchain.prompts import PromptTemplate

# Define a template
template = "You are an AI that summarizes text. Summarize the following: {text}"
prompt = PromptTemplate(input_variables=["text"], template=template)

# Generate a prompt with dynamic input
user_text = "Artificial Intelligence is a field of study that focuses on creating machines capable of intelligent behavior."
formatted_prompt = prompt.format(text=user_text)
print(formatted_prompt)

b) ?? ??

LangChain? OpenAI? GPT ?? Hugging Face ??? ?? LLM? ?????. OpenAI GPT?? ChatOpenAI? ?????.

from langchain.chat_models import ChatOpenAI

# Initialize the model
chat = ChatOpenAI(temperature=0.7, openai_api_key=openai_api_key)

# Generate a response
response = chat.predict("What is Generative AI?")
print(response)

c) ??

??? ?? ??? ??? ?? ?? ???? ?????. ?? ?? ??? ??? ????.

  1. ??? ?????.
  2. ??? ???? ??? ?????.
from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate

# Create a prompt and chain
template = "Summarize the following text: {text}"
prompt = PromptTemplate(input_variables=["text"], template=template)
chain = LLMChain(llm=chat, prompt=prompt)

# Execute the chain
result = chain.run("Generative AI refers to AI systems capable of creating text, images, or other outputs.")
print(result)

d) ??

???? ???? ??? ?? ?? ?? ??? ????? ??? ? ????. ??? ?????.

from langchain.chains import ConversationChain
from langchain.memory import ConversationBufferMemory

# Initialize memory and the conversation chain
memory = ConversationBufferMemory()
conversation = ConversationChain(llm=chat, memory=memory)

# Have a conversation
print(conversation.run("Hi, who are you?"))
print(conversation.run("What did I just ask you?"))

4. ?? ??????

a) ??? ??

????? ???? ???? ???? ???? ?????.

from langchain.chat_models import ChatOpenAI
from langchain.prompts import PromptTemplate

chat = ChatOpenAI(temperature=0.9, openai_api_key=openai_api_key)
prompt = PromptTemplate(input_variables=["topic"], template="Write a poem about {topic}.")
chain = LLMChain(llm=chat, prompt=prompt)

# Generate a poem
result = chain.run("technology")
print(result)

b) ??

??? ???? ????? ?????.

pip install langchain openai python-dotenv streamlit

c) ??

???? ??? ??? ??? ?????.

   OPENAI_API_KEY=your_api_key_here

5. ?? ??

a) ??

??? ? ???? ??????? ?? ?? ??? ???? ? ??? ?????.

   from dotenv import load_dotenv
   import os

   load_dotenv()
   openai_api_key = os.getenv("OPENAI_API_KEY")

b) ??? ??

?? ??? ???? ??? ?????? ?????.

from langchain.prompts import PromptTemplate

# Define a template
template = "You are an AI that summarizes text. Summarize the following: {text}"
prompt = PromptTemplate(input_variables=["text"], template=template)

# Generate a prompt with dynamic input
user_text = "Artificial Intelligence is a field of study that focuses on creating machines capable of intelligent behavior."
formatted_prompt = prompt.format(text=user_text)
print(formatted_prompt)

6. Streamlit? ??? ??

Streamlit? ???? Generative AI ??? ?? ??? ? ?? ?????.

Streamlit ??:

from langchain.chat_models import ChatOpenAI

# Initialize the model
chat = ChatOpenAI(temperature=0.7, openai_api_key=openai_api_key)

# Generate a response
response = chat.predict("What is Generative AI?")
print(response)

??? ?:

from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate

# Create a prompt and chain
template = "Summarize the following text: {text}"
prompt = PromptTemplate(input_variables=["text"], template=template)
chain = LLMChain(llm=chat, prompt=prompt)

# Execute the chain
result = chain.run("Generative AI refers to AI systems capable of creating text, images, or other outputs.")
print(result)

? ??:

from langchain.chains import ConversationChain
from langchain.memory import ConversationBufferMemory

# Initialize memory and the conversation chain
memory = ConversationBufferMemory()
conversation = ConversationChain(llm=chat, memory=memory)

# Have a conversation
print(conversation.run("Hi, who are you?"))
print(conversation.run("What did I just ask you?"))

7. ??? AI ???? ?? ?? ??

a) ?? ?? ??

??? ??????? GPT ?? Stable Diffusion? ?? ??? ?? ???? ??? ?????.

b) ??? ?????

??? ??? ?? ?? ???? ???? ??????.

c) ???? AI

???, ???, ?? ??? ??? ??(?: OpenAI? DALL·E ?? CLIP)? ?????.

d) ?? ? ??

???? ???? Docker? ?? ??? ???? ???? ??? ??? ?????.


8. ???

  • LangChain ??: LangChain Docs
  • OpenAI API: OpenAI Docs
  • ?? ??? ??: ?? ???

? ???? ??? Python ? LangChain? ???? Generative AI ??????? ???? ? ??? ?? ??? ?? ? ????. ??? ????, ????? ????, ???? AI ??? ?? ? ?? ?????!

? ??? LangChain? Python? ??? ?? AI? ?? ???? ??? ??? - 3? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

??? ????
1597
29
PHP ????
1488
72
???
??? ???? ??? ??? ???? ??? Jul 05, 2025 am 02:58 AM

???? Python ?? ?? ?????? ?? ????, "??? ?????, ?? ??"? ???? ??? ??? ??? ?? ??? ?????. 1. ???? ?? ? ??? ?? ?????. ?? ???? ?? ??? ???? ??? ? ? ????. ?? ??, Spoke () ?? ???? ??? ??? ?? ??? ?? ????? ?? ??? ??? ????. 2. ???? ?? ???? ??? ??? ?????? Draw () ???? ???? ????? ?? ???? ?? ??? ???? ??? ???? ?? ?? ?? ??? ????? ?? ?? ????? ?? ?????. 3. Python ?? ???? ???????. ?? ???? ??? ???? ?? ???? ??? ????? ??? ?? ???? ??? ???? ????. ??? ??? ??? ???? ? ??? "?? ??"??????. 4. ???? ? ???? ?? ??? ?????

??? ??? ? ???? ??????. ??? ??? ? ???? ??????. Jul 05, 2025 am 02:55 AM

???? __iter __ () ? __next __ () ???? ???? ?????. ???? ??? ? ??? ????, ?? ???? ?? ??? ??? ???? ?????. 1. ???? ?? () ?? ? ??? ??? ???? ? ?? ??? ?? ? ?? ???? ??? ????. 2. ???? ?? ??? ???? ??? ???? ???? ???? ???? ?? ???? ?????. 3. ???? ???? ?? ??? ?? ? ? ? ??? ?? ? ???????? ? ? ??? ?? ??? ??? ???? ?? ? ? ???? ??????. ?? : ??? ?? ???? ??? ???? ????. ???? ?? ?? ? ??? ?????? ???? ? ?? ?? ? ? ????.

????? API ??? ???? ?? ????? API ??? ???? ?? Jul 13, 2025 am 02:22 AM

API ??? ??? ??? ?? ??? ???? ???? ???? ????. 1. Apikey? ?? ??? ?? ????, ????? ?? ?? ?? URL ?? ??? ?????. 2. Basicauth? ?? ???? ??? Base64 ??? ??? ??? ??? ????? ?????. 3. OAUTH2? ?? Client_ID ? Client_Secret? ?? ??? ?? ?? ?? ??? BearEtroken? ???????. 4. ?? ??? ???? ?? ?? ?? ???? ????? ???? ?? ?? ? ????. ???, ??? ?? ??? ??? ???? ?? ??? ???? ???? ?? ?????.

??? ??? ??????. ??? ??? ??????. Jul 07, 2025 am 12:14 AM

Assert? ????? ???? ???? ?? ? ???? ??? ???? ??? ?? ?? ????. ??? ??? ??? ?? ??? ?????, ?? ?? ?? ??, ?? ?? ?? ?? ?? ?? ??? ????? ?? ?? ??? ?? ???? ??? ? ??? ??? ??? ??? ?? ???????. ?? ??? ???? ?? ?? ???? ?? ????? ??? ? ????.

? ?? ? ??? ???? ?? Python ? ?? ? ??? ???? ?? Python Jul 09, 2025 am 01:13 AM

????? ??? ? ??? ??? ?? ??? ???? ??? zip () ??? ???? ????.? ??? ?? ??? ???? ?? ??? ?? ????. ?? ??? ???? ?? ?? itertools.zip_longest ()? ???? ?? ?? ? ??? ?? ? ????. enumerate ()? ???? ??? ???? ?? ? ????. 1.zip ()? ???? ????? ?? ??? ??? ??? ?????. 2.zip_longest ()? ???? ?? ??? ?? ? ? ???? ?? ? ????. 3. Enumental (Zip ())? ??? ??? ????? ??? ???? ???? ?? ???? ?? ? ????.

??? ???? ?????? ??? ???? ?????? Jul 08, 2025 am 02:56 AM

inpython, iteratorsareobjectsthatlowloppingthroughcollections __ () ? __next __ ()

??? ?? ??? ?????? ??? ?? ??? ?????? Jul 07, 2025 am 02:55 AM

typehintsinpythonsolvetheproblemombiguityandpotentialbugsindynamicallytypedcodebyallowingdevelopscifyexpectiontypes. theyenhancereadability, enablearylybugdetection ? improvetoomingsupport.typehintsareaddedusingaColon (:) forvariblesAndAramete

Python Fastapi ???? Python Fastapi ???? Jul 12, 2025 am 02:42 AM

Python? ???? ????? ???? API? ???? Fastapi? ?????. ?? ??? ?? ????? ?????? ??? ??? ??? ???? ?? ? ? ????. Fastapi ? Asgi Server Uvicorn? ?? ? ? ????? ??? ??? ? ????. ??? ??, ?? ?? ?? ? ???? ?????? API? ???? ?? ? ? ????. Fastapi? ??? HTTP ??? ???? ?? ?? ? Swaggerui ? Redoc Documentation Systems? ?????. ?? ??? ?? URL ?? ??? ?? ? ??? ??, ?? ?? ??? ???? ???? ?? ?? ??? ??? ? ????. Pydantic ??? ???? ??? ?? ???? ???? ????? ? ??? ? ? ????.

See all articles