国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? ??? ?? ??? ???? 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)

???

??? ??

?? ????
1783
16
Cakephp ????
1728
56
??? ????
1577
28
PHP ????
1442
31
???
Python? Unittest ?? Pytest ??? ??? ??? ??? ? ???? ?????? Python? Unittest ?? Pytest ??? ??? ??? ??? ? ???? ?????? Jun 19, 2025 am 01:10 AM

Python? Unittest ? Pytest? ??? ? ???? ??, ?? ? ??? ????? ? ?? ?? ???? ??? ??? ?????. 1. ??? ??? ?? ??? ???? ??? ??? ??? ?????. UnitTest? ??? ??? ???? ???? Test \ _? ???? ???? ?????. Pytest? ? ?????. Test \ _?? ???? ?? ? ??????. 2. ??? ?? ?? ? ?? ? ??? ??? ????. UnitTest? Assertequal, AssertTrue ? ?? ??? ???? ?? Pytest? ??? Assert ?? ???? ?? ?? ??? ???? ?????. 3. ?? ??? ?? ? ?? ????? ????? ????.

Numpy ? Pandas? ?? ??????? ??? ?? ? ??? Python? ??? ??? ? ????? Numpy ? Pandas? ?? ??????? ??? ?? ? ??? Python? ??? ??? ? ????? Jun 19, 2025 am 01:04 AM

pythonisidealfordataanalysisduetonumpyandpandas.1) numpyexcelsatnumericalcomputationsfast, multi-dimensionalArraysandectorizedOferationsLikenp.sqrt ()

?? ????? ???? ???? Python?? ??? ?????? ?? ????? ???? ???? Python?? ??? ?????? Jun 20, 2025 am 12:57 AM

?? ????? (DP)? ??? ??? ? ??? ?? ??? ??? ??? ? ??? ??? ?? ??? ???? ??? ????? ??????. ? ?? ?? ??? ????. 1. ??? (??) : ??? ?? ??? ???? ??? ???? ?? ??? ??????. 2. ??? (?) : ?? ???? ???? ????? ?????. ???? ???, ?? ?? ?? ?? ??/?? ?, ??? ??? ?? ?? ?? ??? ??? ????? ?????. ?????? ????? ?? ???? ?? ??? ? ???, ?? ??? ???? ?? ?? ??? ???? ??? ???? ????? ???? ???????.

__iter__ ? __next__? ???? ????? ??? ?? ???? ??? ??? ? ????? __iter__ ? __next__? ???? ????? ??? ?? ???? ??? ??? ? ????? Jun 19, 2025 am 01:12 AM

??? ?? ???? ????? ????? __iter_ ? __next__ ???? ???????. ① __iter__ ???? ??? ? ?? ??? ???? ??? ?? ?? ??? ?????. ② __next__ ???? ? ??? ?? ????, ?? ??? ??? ????, ? ?? ??? ??? stopiteration ??? ??????. status ??? ???? ??????? ?? ??? ??? ?? ?? ??? ???????. pile ?? ?? ???? ?? ??? ?? ? ??? ?? ? ??? ?????? ?????. simple ??? ??? ?? ?? ??? ?? ???? ???? ?? ??? ? ??? ?? ????? ???? ??? ??? ???????.

Python ????? ??? ???? ??? ??? ?? ?? ??? ?????? Python ????? ??? ???? ??? ??? ?? ?? ??? ?????? Jun 19, 2025 am 01:09 AM

Python? ?? ???? ?? ???, ?? ?? ????, ?? ???? ?? ? AI/ML ??? ???? ??? ?????. ??, Cpython? ???? ????? ?? ??, ?? ?? ??? ? ?? ? ?? ??? ?? ??? ??????. ??, ??? ????? ?? ?? ? ?? ??? ????? ?? ?? ? ? ??? ?? ?????. ??, Pyscript ? Nuitka? ?? ?? ???? ??? ??? ?? ??? ?????. ?????, AI ? ??? ?? ??? ?? ???? ??? ?? ???????? ???? ?? ? ??? ?????. ??? ??? Python? ??? ??? ????? ???? ?? ??? ???? ??? ?????.

??? ???? ????? ???? ?????? ??? ?????? ??? ???? ????? ???? ?????? ??? ?????? Jun 20, 2025 am 12:56 AM

Python? ?? ??? ???? ?????? ????, ????? ? ?? ??????? ???? ? ??? ??? ???? ?? ??? ?????. ?? TCP ??? ????? Socket.Socket ()? ???? ??? ??? ?? ? ??? ????? .listen ()? ???? ??? ?? .accept ()? ?? ????? ??? ???????. TCP ?????? ????? ?? ??? ??? ??? ????? .connect ()? ?? ? ?? .sendall ()? ???? ???? ??? .recv ()? ?? ??? ??????. ?? ?????? ????? 1. ??? : ??? ??? ? ???? ??? ? ????. 2. ??? I/O : ?? ??, Asyncio ?????? ? ??? ??? ?? ? ? ????. ???? ? ?

??? ???? ??? ??? ???? ??? Jul 05, 2025 am 02:58 AM

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

Python?? ??? ??? ???????? Python?? ??? ??? ???????? Jun 20, 2025 am 12:51 AM

Python List ????? ?? ?? ??? [Start : End : Step] ??? ????? ??? ???? ????. 1. ?? ????? ?? ??? ?? [start : end : step]???. ??? ?? ??? (??), ?? ? ??? (???? ??)?? ??? ?? ?????. 2. ????? ???? 0?? ????? ???? ????? ??? ??? ???? ????? ??? 1? ??????. 3. my_list [: n]? ???? ? ?? n ??? ?? my_list [-n :]? ???? ??? n ??? ????. 4. My_List [:: 2]? ?? ??? ?? ?? ??? ???? ??? ??? ?? ?? ?? ??? ???? ? ????. 5. ???? ???? ? ???? ???? ????

See all articles