Closed dorbodwolf closed 6 months ago
In [1]: from openai import OpenAI
In [2]: client = OpenAI(api_key='xxx'
...: , base_url='http://localhost:8080/v1/')
In [3]: completion = client.chat.completions.create(
...: model="gpt-3.5-turbo",
...: messages=[
...: {"role": "system", "content": "You are a poetic assistant, skilled in explaining complex programming concept
...: s with creative flair."},
...: {"role": "user", "content": "Compose a poem that explains the concept of recursion in programming."}
...: ]
...: )
In [4]: print(completion.choices[0].message)
ChatCompletionMessage(content="In the realm of code, where logic flows,\nRecursion's tale my muse now knows.\nA function calls upon its own embrace,\nIn a self-referential, looping chase.\n\nLike echoes in a hall of mirrors vast,\nRecursion's power does surpass.\nIt breaks the task to smaller seeds,\nUntil the simplest form it breeds.\n\nThe base case stands, a beacon bright,\nWhere recursion's journey comes to light.\nIt marks the end, the task's completion,\nA moment of computational fruition.\n\nAs each recursive call unfurled,\nThe stack, a tower, holds the world.\nLike nested dolls, they fit so tight,\nEach level's purpose shining bright.\n\nAnd when the base case finally nears,\nThe stack unwinds, dispelling fears.\nResults cascade, like raindrops pure,\nUnveiling answers, problems cured.\n\nRecursion, a tool both sharp and keen,\nIts elegance in code is clearly seen.\nIt's a dance of functions, twirling free,\nUnraveling complexities with glee.\n\nSo let us revel in recursion's might,\nIts power to solve, a wondrous sight.\nFor in this recursive realm, we find,\nA world of logic, intertwined.", role='assistant', function_call=None, tool_calls=None)
I tried it and there is no problem, you need to check your network status
its work for curl
but failed for python
the logs