mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
@@ -278,8 +278,10 @@ class ChatFireworks(BaseChatModel):
|
||||
.. code-block:: python
|
||||
|
||||
from langchain_fireworks.chat_models import ChatFireworks
|
||||
|
||||
fireworks = ChatFireworks(
|
||||
model_name="accounts/fireworks/models/llama-v3p1-8b-instruct")
|
||||
model_name="accounts/fireworks/models/llama-v3p1-8b-instruct"
|
||||
)
|
||||
|
||||
"""
|
||||
|
||||
@@ -825,7 +827,10 @@ class ChatFireworks(BaseChatModel):
|
||||
)
|
||||
|
||||
|
||||
llm = ChatFireworks(model="accounts/fireworks/models/firefunction-v1", temperature=0)
|
||||
llm = ChatFireworks(
|
||||
model="accounts/fireworks/models/firefunction-v1",
|
||||
temperature=0,
|
||||
)
|
||||
structured_llm = llm.with_structured_output(AnswerWithJustification)
|
||||
|
||||
structured_llm.invoke(
|
||||
@@ -852,7 +857,10 @@ class ChatFireworks(BaseChatModel):
|
||||
justification: str
|
||||
|
||||
|
||||
llm = ChatFireworks(model="accounts/fireworks/models/firefunction-v1", temperature=0)
|
||||
llm = ChatFireworks(
|
||||
model="accounts/fireworks/models/firefunction-v1",
|
||||
temperature=0,
|
||||
)
|
||||
structured_llm = llm.with_structured_output(
|
||||
AnswerWithJustification, include_raw=True
|
||||
)
|
||||
@@ -886,7 +894,10 @@ class ChatFireworks(BaseChatModel):
|
||||
]
|
||||
|
||||
|
||||
llm = ChatFireworks(model="accounts/fireworks/models/firefunction-v1", temperature=0)
|
||||
llm = ChatFireworks(
|
||||
model="accounts/fireworks/models/firefunction-v1",
|
||||
temperature=0,
|
||||
)
|
||||
structured_llm = llm.with_structured_output(AnswerWithJustification)
|
||||
|
||||
structured_llm.invoke(
|
||||
@@ -904,19 +915,25 @@ class ChatFireworks(BaseChatModel):
|
||||
from langchain_fireworks import ChatFireworks
|
||||
|
||||
oai_schema = {
|
||||
'name': 'AnswerWithJustification',
|
||||
'description': 'An answer to the user question along with justification for the answer.',
|
||||
'parameters': {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'answer': {'type': 'string'},
|
||||
'justification': {'description': 'A justification for the answer.', 'type': 'string'}
|
||||
"name": "AnswerWithJustification",
|
||||
"description": "An answer to the user question along with justification for the answer.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"answer": {"type": "string"},
|
||||
"justification": {
|
||||
"description": "A justification for the answer.",
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
'required': ['answer']
|
||||
}
|
||||
"required": ["answer"],
|
||||
},
|
||||
}
|
||||
|
||||
llm = ChatFireworks(model="accounts/fireworks/models/firefunction-v1", temperature=0)
|
||||
llm = ChatFireworks(
|
||||
model="accounts/fireworks/models/firefunction-v1",
|
||||
temperature=0,
|
||||
)
|
||||
structured_llm = llm.with_structured_output(oai_schema)
|
||||
|
||||
structured_llm.invoke(
|
||||
|
||||
@@ -35,7 +35,7 @@ class FireworksEmbeddings(BaseModel, Embeddings):
|
||||
from langchain_fireworks import FireworksEmbeddings
|
||||
|
||||
model = FireworksEmbeddings(
|
||||
model='nomic-ai/nomic-embed-text-v1.5'
|
||||
model="nomic-ai/nomic-embed-text-v1.5"
|
||||
# Use FIREWORKS_API_KEY env var or pass it in directly
|
||||
# fireworks_api_key="..."
|
||||
)
|
||||
@@ -44,7 +44,7 @@ class FireworksEmbeddings(BaseModel, Embeddings):
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
vectors = embeddings.embed_documents(['hello', 'goodbye'])
|
||||
vectors = embeddings.embed_documents(["hello", "goodbye"])
|
||||
# Showing only the first 3 coordinates
|
||||
print(len(vectors))
|
||||
print(vectors[0][:3])
|
||||
@@ -59,7 +59,7 @@ class FireworksEmbeddings(BaseModel, Embeddings):
|
||||
.. code-block:: python
|
||||
|
||||
input_text = "The meaning of life is 42"
|
||||
vector = embeddings.embed_query('hello')
|
||||
vector = embeddings.embed_query("hello")
|
||||
print(vector[:3])
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
Reference in New Issue
Block a user