Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Symphony – Use GPT-4 to call functions in sequence (symphony.run)
93 points by jrmyphlmn on Sept 20, 2023 | hide | past | favorite | 33 comments
Hey HN!

I'm excited to introduce Symphony – a toolkit designed to help developers write functions and let GPT-4 call them in whatever sequence that makes most sense based on conversation.

I've been quite amazed[1] by GPT-4's recent ability to both detect when a function needs to be called and to respond with JSON that adheres to the function's signature.

Since developers currently append descriptions of functions to API calls[2], I often found myself wishing for a toolkit that would automatically create these descriptions as I added and debugged functions during development.

You can get started by cloning the repository and adding functions by following the guide at https://symphony.run/docs

As of now, the toolkit supports functions in TypeScript. I'll be adding support for more languages and features based on your feedback :)

[1] - Symphony Showcase: https://symphony.run/showcase

[2] - Function calling and other API updates from OpenAI: https://openai.com/blog/function-calling-and-other-api-updat...




Nice. Just to point out, calling a sequence of functions is what GPT-4 does automatically if you keep feeding it the responses and it is clear to it that is necessary given it's instructions.

So the main point of this seems to be extracting the interface from the module and converting it into the OpenAI API call's functions format.

It's a good idea. But for me I would rather just have an npm package with a function like

  extractFunctions(srcFilename)
which I could then use inside of my own project which already handles the rest of it.


Thank you! You're right; the main focus right now is extraction.

One aspect I'm excited about is the possibility of rendering the JSON outputs from these function calls into UI components, as previewed here: https://symphony.run/showcase. Using a function's type definitions is a nice starting point to embed interfaces into the conversation.

Additionally, I hope to make the toolkit language-agnostic. I'd like to incorporate some of my .py and .rs scripts to make them ready for use as well. Not sure if packaging it as an npm package would go against that objective, but will definitely consider :)


Well, this knows when to stop calling GPT-4, which seems non-trivial.


ChatGPT does this automatically, if you pass in `function_call: "auto"`


How would this work? Say I need multiple function calls to handle a user prompt. OpenAI will only supply one function call at a time. My understanding is that "auto" just lets it choose which function to call, but you still have to know that you need to call it multiple times, and when to stop.


It can make multiple function calls. For example I have it hooked up to edit word documents, and I can say "create a word document, add a paragraph describing yourself and then add title 'xyz'" and it will make three separate function calls to do this before responding saying that it's completed the task.


Yep. I built this for Python recently and it uses introspection to automatically build this same info. It's maybe 100 lines in total? The OpenAI API is pretty amazing.


That sounds great! I'm currently working on adding support for .py files as well – open to PRs :)


Have you packaged or shared your codebase? If so would love to see it!


Love this! I’m an fp-ts and xstate fan and am happy to see them in this usecase. My intuition tells me that state machines with llm directed function calling is going to be a huge unlock. One thing I’m curious about is narrowing the scope of accessible functions based on a state machine that is designed to match the business domain. This might involve machine to machine communication which I know XState supports


Thanks!

> state machines with llm directed function calling is going to be a huge unlock

This was my intuition as well, glad you're able to resonate with that :)

> One thing I’m curious about is narrowing the scope of accessible functions based on a state machine that is designed to match the business domain.

This is an interesting question, I can definitely see how state machines can help with narrowing the scope of accessible functions.


I tried TypeChat for my use case and ended up defining functions as typescript data types. This approach sounds much better, and leverages the newer OpenAI function calling, which should be more reliable I would think. Thanks for creating+sharing.

https://microsoft.github.io/TypeChat/


Thanks, excited to hear what you think after trying it out :)


Is there still an absolutely pathetic amount of GPT4 calls per day? I pay the $20 to chatgpt but I never ever pick GPT4 because 10 minutes into an AI directed conversation I'll get the "sorry ur out of gpt4 today" message. The only time I wind up using that limit is when I don't even realize it's using it. I have no idea what the difference actually is because its limit is to low for me to even consider relying on over 3.5.


Try using the API. There are multiple open source ChatGPT clones or terminal clients. The API limits are not a problem for an individual.


Be really helpful to me and maybe others if you could let us know what 'Clones' you know of?, as I struggle to find them, thanks.


Search "open source chatgpt client" and you will get dozens.


I am a happy user of Chatbox.


No it's been OK the last month or 2


First thing I thought when reading the title was "some AI for Symphony PHP, interesting". I know its hard to name things at this point, these clashes are just going to happen with so many projects over the last 50 years. But at some point I think clashing with a project in such heavy use is just a detriment to the brand.


It's worth noting that the PHP framework is spelled "Symfony."


If I'm understanding correctly, this makes all of the functions available to gpt-4 at once and then gpt-4 decides which one to use, right? What are the limits on the number and length of functions, and is there any way to choose only a subject of the functions to share for a given user query?


Pretty cool that this is a recreation of expert systems, which was a dominant approach to building AIs for decades :)


Expert systems except it's like 400 times more expensive to run.


Sure, but also 400 times (at least...) more versatile and more error prone.

Determinism was one of the things that the expert systems of old did reasonably well. The current incarnation feels like playing Russian Roulette but with three bullets rather than just one.


You're right!

IIRC, only the function signatures (or descriptions) are counted as part of the context window so you could add as many till you exceed that limit. Since the contents of the function itself are not counted, your function can be whatever length.

> is there any way to choose only a subject of the functions to share for a given user query?

As of now, no. I can see why this may be a problem soon since right now all functions are available for gpt-4 and each call can become expensive pretty quickly if you send like 50 functions every time.

I'm not sure how to address this yet, but I'd like to think of it as some form of fine-tuning that happens after having a few conversations. Will keep you in the loop!


Ah, that makes sense. So on their end they’re just passing the descriptions to the llm (plus some wrapper to let it know it’s a func) and then they pipeline the data in and out of the chosen function. That has always confused me but I think I get it now. Thanks!


Sure, give the LLM a discovery function. If you're trying to figure out what tools to give the LLM based on user input, you're probably squandering the main power of the pattern.


This is really cool. Love to see usage of state machines on the backend!

It's such a good fit for multi-step LLM apps and a really nice abstraction for generic backend flows as well.


Thank you :)


Nice. We (Delphi[0] - enterprise AI data assistant) do something similar internally to power our app.

We’re all typescript under the hood so I’ll give this a look and see if we can use it.

Symphony wouldn’t support other LLMs currently, right? Only GPT-4?

[0] https://delphihq.com


Glad to hear that!

Right, currently Symphony only supports GPT-4 and GPT-3.5-turbo since they're the only ones with native API support.


How is it different from LangChain?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: