Replies: 4 comments 6 replies
-
More or less : the function that generates openapi is a build-time function that operates at the level of the
I actually think it's a good idea ! And also pretty straightforward to do, relatively to, say, implementing RESTful protocols like
There's the
It absolutely does : we're very much making all of our decisions to ensure that downstreams are able to implement protocols on top of the constructs of smithy4s-core. Nothing in the generated code of smithy4s is protocol specific, nor is it biased towards any usecase. The generated code contains instances of the abstractions you need to implement the usecase you're describing :)
I don't think so : although we're breaking a few things, overall the stuff you need to build this functionality is not gonna be greatly impacted. Alternatively, we have snapshots of the 0.18 branch if you want to develop against the bleeding-edge. It may be easier to give you a hand if you do, as our heads are very much in 0.18 at the moment. Latest snapshot we've released is
Yes, click here. This is a toy implementation of client/server interpreters for a The "server" essentially responds to requests that look like this : {
"OperationName" : JsonEncodedInput
} so if you have : operation Foo {
input: = {
@required
str: String
@required
num: Integer
}
} then the following would be a valid request : {
"Foo" : {
"str": "hello",
"num": 1
}
} This should be sufficient to get you started :) |
Beta Was this translation helpful? Give feedback.
-
@Baccata I spent some time yesterday, sketching out the interactions with openAIs API - basically following their examples. I've realised, that there is some complexity in the control flow - but my view is that would clearly be "out of scope" of what I'm trying to achieve with smithy. I think it should be left to the caller. My goal here is only to enable the function calling. Concretely, my goal would be to abstract this part with a call to newSmithyTool: And replace this "fakeFct" with the dispatcher you pointed me at above. Planned Path To Victory:
Before I pour lots more time into this... I'd love to know if you thought that's a reasonable plan of attack / outcome? |
Beta Was this translation helpful? Give feedback.
-
@Baccata @kubukoz So as you are by now aware, I experienced a complete and catastrophic loss of self control as my curiosity got the better of me. https://github.com/Quafadas/smithy-call-tool is now a viable POC for the goal I outlined above.
It'll work for services and operations which can be described by the below subset of smithy. |
Beta Was this translation helpful? Give feedback.
-
Hi Guys, I've had another look at this. As far as I can tell, my experiment produces valid JSON schema, under a wide range of conditions. It is incomplete in a few places (e.g. tagged unions), but this is my best starting point at a PR with the aim to introduce JSON schema generation. I guess I'd welcome feedback on whether it's worth continuing / how to go about / roughly how far away you perceive a PR to smithy itself might be? Here is my suggestion, on how you could investigate. Step 1.https://github.com/Quafadas/smithy-call-tool/blob/main/src/test/scala/json.schema.test.scala The "example generation" test contains the finished schema gen, with both the shape and defs . Stick a breakpoint at the end, and skim the test debug log. The assertions compare AWS generated schema, against this "homegrown" approach. By playing with the smithy spec defined above and treating this as a black box, you should be able to fairly quickly gain a picture, of whether you think it's worth spending more of your time, looking into this, or not. To be clear if not : that would also be okay! My experiments are that most of the time it produced valid schema - even if it often fails the "test" by not being the same as AWS. Usually, AWS has a different set of defs. Step 2This should give you a feel, of whether it's possible to put on a "correctness collar" to keep it maintainable. My standard here will be lower than yours - as I don't maintain major projects. I left a failing test in, to show that this is, sadly, not complete. In part that could provoke a discussion on how to break up a potential PR into smaller chunks? Step 3Skim the implementations themselves. I think everything you might be interested in, is in the By my standards, the implementation is complex. It's probably messy in places. I am open to feedback. I am happy, to join a call to explain, as best I can, how / what / why, if that is helpful or you find anything unclear. |
Beta Was this translation helpful? Give feedback.
-
An idea. OpenAI recently built calling third party tools, right into their API.
https://openai.com/blog/function-calling-and-other-api-updates
For chatGPT to be really useful for me, I need to be able to tell it about my domain, and lots of my domain data is in private APIs… that I now have smithy definitions for :-). So I begin to wonder, if I can take advantage of all this somehow. What I realised that an awful lot of what I would need do, is already in Smithy in some form or another.
Here’s the notion - currently, I use two “targets“ provided by
@simpleRestJson
:X extends SmithyService[IO]
, andSimpleRestJsonBuilder.apply(SmithyService)
The idea, would be to add a third “target” let’s call it
GPTool
. Instantiated likeval gptTool = GPTool.apply(List(anInstanceOfASmithyServce))
it exposes two methods:gptTool.toolJson
- generates a description of the JSON Schema to feed to the AI, telling it about the list oftools
(endpoints) defined in the smithy specs. As smithy produces openAI specs already… in my head the heavy lifting is already done? It would be simply a question of extracting a subset?https://platform.openai.com/docs/api-reference/chat/create#chat/create-functions
And
gptTool.functionCall()
which, given the JSON constructed by the LLM, calls our actual scala implementation of the service. I think this part would be a (relatively hides) simple problem. At heartJSON => JSON
with a pattern match on the method name given by the LLM ...So… my questions.
Is here an obvious “This isn’t going to work because X”, “this is a horrid idea” type problem with this?
The big one I see, is the “description” part of openAIs examples. Which I think would require something in the smithy specs themselves. On a Hail Mary: is there a “description” annotation already :-)? In my head, this might be a nasty “might need changes to smithy4s itself which are above my pay grade” kind of problem. So in a first pass… I might skip it (i.e leave them blank) and see if there's any value here first. I think this is the most awkward problem I saw.
I assume, that this is a bit niche for the “main” smithy repo itself due to maintenance concerns etc ? Would the published smithy artefact, expose enough functionality to be able to implement something like this on top of it downstream?
If the answer to all the above, is yes, has anyone followed enough to set out a more detailed solution sketch … i.e. put my feet on the path? I'll gladly answer more questions on the the thought process if anyone is interested enough to have them!
I’ve been lurking the discord … would it be worth waiting for 0.18, to attempt such a thing?
Is anyone interested enough to want to have a go, at shaving this yak with me :-)?
Beta Was this translation helpful? Give feedback.
All reactions