Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding output parsers to spaces #3

Closed
itsyogesh opened this issue Mar 14, 2023 · 5 comments
Closed

Adding output parsers to spaces #3

itsyogesh opened this issue Mar 14, 2023 · 5 comments

Comments

@itsyogesh
Copy link

There is a lot of work that's happening around llm outputs. Some interesting things we can look at:

https://hwchase17.github.io/langchainjs/docs/modules/prompts/output_parsers/

https://github.com/shreyar/guardrails

https://eyurtsev.github.io/kor/index.html

We can look at specific implementations that are described here or we can build one from scratch.

@dosco
Copy link
Collaborator

dosco commented Mar 15, 2023

Thanks this looks cool i'll dig in deeper. There are two built in output parsers in GenerateText both are used based on Prompt metadata for example. the param keyValueResponse: true enables splitting the response using a colon seperator.

  1. Key Value Output:
    https://github.com/dosco/minds/blob/50e864f91806c2d723fe6edd46bc3a6a2ecd17d8/src/prompts/extract.ts#L75

  2. Tools / Actions but this one is used internally:
    https://github.com/dosco/minds/blob/50e864f91806c2d723fe6edd46bc3a6a2ecd17d8/src/prompts/answers.ts#L46

I tend to add features based on uses-cases so will try and figure out some to extending our current output parsing the zod librasry that langchain uses can be used by us as well.

@dosco
Copy link
Collaborator

dosco commented May 22, 2023

just finished a big refactor to make the api simpler to use and extend. also added support for zod. we now have output parser support for plaintext, simple key-value or a zod schema built in.

The prompts are now super-simple and mostly extend from AIPrompt which does all the heavy lifting. For example see the
https://github.com/dosco/minds/blob/main/src/prompts/zprompt.ts

const prompt = new ZPrompt(zodSchema, actions);
const CustomerResponse = z.object({
  data: z
    .array(
      z.object({
        name: z.string().describe('product name'),
        units: z.number().describe('units in stock'),
        desc: z.string().max(15).describe('product description'),
      })
    )
    .describe('inventory information'),
  response: z.string().max(50).describe('customer response'),
});

const prompt = new ZPrompt(CustomerResponse, actions);

@dosco dosco closed this as completed Jul 18, 2023
@Madd0g
Copy link

Madd0g commented Jun 26, 2024

Are ZPrompt or zod (or grammars) supported currently? I couldn't find anything

@dosco
Copy link
Collaborator

dosco commented Jun 27, 2024

The whole framework has changed significantly and is now based on the prompt as. a program idea from the Stanford DSP paper. while zod is not supported anymore it's not required you can have typed inputs and outputs on the prompt (prompt signature)

@dosco
Copy link
Collaborator

dosco commented Jun 27, 2024

And you can use asserts to integrate with zod if you still need to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants