docs: drop docs changes from this PR (defer to follow-up)
Restores docs/v3/documentation/features/chat.mdx to main's version. This also puts back the peer-chat Structured Outputs section (#896) that the workspace-chat commit removed as a rebase artifact. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
1af690bcdb
commit
e15123a997
|
|
@ -94,6 +94,43 @@ for await (const chunk of responseStream.iter_text()) {
|
|||
|
||||
Streaming is useful for displaying real-time responses in chat interfaces or when asking complex questions that require longer answers.
|
||||
|
||||
## Structured Outputs
|
||||
|
||||
When your application needs a machine-readable answer instead of prose, pass a schema as `response_format` and the answer is guaranteed to conform to it:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
from pydantic import BaseModel
|
||||
|
||||
class OnboardingStatus(BaseModel):
|
||||
completed: bool
|
||||
remaining_steps: list[str]
|
||||
|
||||
status = peer.chat(
|
||||
"Has the user completed the onboarding flow?",
|
||||
response_format=OnboardingStatus,
|
||||
)
|
||||
# status is a parsed OnboardingStatus instance
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
import { z } from 'zod';
|
||||
|
||||
const OnboardingStatus = z.object({
|
||||
completed: z.boolean(),
|
||||
remainingSteps: z.array(z.string()),
|
||||
});
|
||||
|
||||
const status = await peer.chat(
|
||||
"Has the user completed the onboarding flow?",
|
||||
{ responseFormat: OnboardingStatus },
|
||||
);
|
||||
// status is typed as z.infer<typeof OnboardingStatus>
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
The agent runs its full reasoning loop either way — only the final answer is formatted to your schema. See [Structured Outputs](/v3/documentation/features/advanced/structured-outputs) for the supported schema subset, streaming behavior, and best practices.
|
||||
|
||||
## Integration Patterns
|
||||
|
||||
### Dynamic Prompt Enhancement
|
||||
|
|
@ -189,48 +226,6 @@ const goals = await peer.chat("What are the user's main goals or objectives?");
|
|||
```
|
||||
</CodeGroup>
|
||||
|
||||
## Workspace-Level Chat
|
||||
|
||||
While `peer.chat()` queries knowledge about a single peer, `honcho.chat()` searches across **all peers and observations** in the workspace. This is useful for cross-peer analysis, discovering common themes, or asking workspace-wide questions.
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
from honcho import Honcho
|
||||
|
||||
honcho = Honcho()
|
||||
|
||||
# Ask about the entire workspace
|
||||
answer = honcho.chat("What are common themes across all users?")
|
||||
print(answer)
|
||||
|
||||
# With streaming
|
||||
stream = honcho.chat_stream("Summarize all peer activity this week.")
|
||||
for chunk in stream:
|
||||
print(chunk, end="", flush=True)
|
||||
|
||||
# Async
|
||||
answer = await honcho.aio.chat("Which users have discussed topic X?")
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
import { Honcho } from '@honcho-ai/sdk';
|
||||
|
||||
const honcho = new Honcho({});
|
||||
|
||||
// Ask about the entire workspace
|
||||
const answer = await honcho.chat("What are common themes across all users?");
|
||||
console.log(answer);
|
||||
|
||||
// With streaming
|
||||
const stream = await honcho.chatStream("Summarize all peer activity this week.");
|
||||
for await (const chunk of stream) {
|
||||
process.stdout.write(chunk);
|
||||
}
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
Workspace chat accepts `reasoning_level` and optional `session` scoping. For streaming, use the separate `chat_stream()` / `chatStream()` method rather than a `stream` parameter.
|
||||
|
||||
## How Honcho Answers
|
||||
|
||||
When you call `peer.chat(query)`:
|
||||
|
|
|
|||
Loading…
Reference in New Issue