diff --git a/guidance/llms/_openai.py b/guidance/llms/_openai.py index 6be8281fd..e946479ba 100644 --- a/guidance/llms/_openai.py +++ b/guidance/llms/_openai.py @@ -108,7 +108,7 @@ def __init__(self, model=None, caching=True, max_retries=5, max_calls_per_min=60 self._tokenizer = tiktoken.get_encoding("cl100k_base") self.chat_mode = chat_mode - self.model = model + self.model_name = model self.caching = caching self.max_retries = max_retries self.max_calls_per_min = max_calls_per_min @@ -169,7 +169,7 @@ def __call__(self, prompt, stop=None, stop_regex=None, temperature=None, n=1, ma try: self.add_call() call_args = { - "model": self.model, + "model": self.model_name, "prompt": prompt, "max_tokens": max_tokens, "temperature": temperature, diff --git a/notebooks/anachronism.ipynb b/notebooks/anachronism.ipynb index 23f1f6dd9..96839a4b4 100644 --- a/notebooks/anachronism.ipynb +++ b/notebooks/anachronism.ipynb @@ -165,6 +165,14 @@ "print('Few-shot', (np.array(labels) == fews).mean())\n", "print('Structured output', (np.array(labels) == structs).mean())" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
systemYou are a helpful assistant.\n",
"
systemYou are a helpful assistant.What is the meaning of life?\n",
"Who are 3 world-class experts (past or present) who would be great at answering this?\n",
"Please don't answer the question or comment on it yet.
systemYou are a helpful assistant.How can I be more productive?\n",
"Who are 3 world-class experts (past or present) who would be great at answering this?\n",
"Please don't answer the question or comment on it yet.
userWho are the founders of OpenAI?assistantThe founders of OpenAI are Sam Altman, Reid Hoffman, Jessica Livingston, Elon Musk, Ilya Sutskever, Peter Thiel and others.
systemYou are a helpful assistant.userFrom now on, whenever your response depends on any factual information, please search the web by using the function <search>query</search> before responding. I will then paste web results in, and you can respond.assistantOk, I will do that. Let's do a practice rounduserWho are the founders of OpenAI?assistant<search>OpenAI founders</search>userSearch results:\n", + "systemYou are a helpful assistant.userFrom now on, whenever your response depends on any factual information, please search the web by using the function <search>query</search> before responding. I will then paste web results in, and you can respond.assistantOk, I will do that. Let's do a practice rounduserWho are the founders of OpenAI?assistant<search>OpenAI founders</search>userSearch results:\n", "<result>\n", "OpenAI - Wikipedia\n", "OpenAI systems run on the fifth most powerful supercomputer in the world. [5] [6] [7] The organization was founded in San Francisco in 2015 by Sam Altman, Reid Hoffman, Jessica Livingston, Elon Musk, Ilya Sutskever, Peter Thiel and others, [8] [1] [9] who collectively pledged US$ 1 billion. Musk resigned from the board in 2018 but remained a donor.\n", @@ -736,8 +746,9 @@ "Sam Altman - Wikipedia\n", "Samuel H. Altman ( / ˈɔːltmən / AWLT-mən; born April 22, 1985) is an American entrepreneur, investor, and programmer. [2] He is the CEO of OpenAI and the former president of Y Combinator. [3] [4] Altman is also the co-founder of Loopt (founded in 2005) and Worldcoin (founded in 2020). Early life and education [ edit]\n", "</result>assistantThe founders of OpenAI are Sam Altman, Reid Hoffman, Jessica Livingston, Elon Musk, Ilya Sutskever, Peter Thiel and others.userThat was great, now let's do another one.assistantOk, I'm ready.userWhat is Microsoft's stock price right now?\n", + "assistant<search>Microsoft stock price</search>\n", + "" ] }, "metadata": {}, @@ -792,13 +800,13 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "assistant<search>Microsoft stock price</search>\n", - "<|im_start|>user\n", - "Search results:\n", - "" + "{{~/assistant}}'>userSearch results: \n", "<result>\n", "Microsoft Corp (MSFT) Stock Price & News - Google Finance\n", - "Microsoft Corp (MSFT) Stock Price & News - Google Finance Home MSFT • NASDAQ Microsoft Corp Follow Share $288.30 After Hours: $288.54 (0.083%) +0.24 Closed: Mar 31, 7:59:31 PM GMT-4 ·...\n", + "Microsoft Corp (MSFT) Stock Price & News - Google Finance Home MSFT • NASDAQ Microsoft Corp Follow Share $288.37 After Hours: $287.86 (0.18%) -0.51 Closed: Apr 18, 5:57:32 PM GMT-4 ·...\n", "</result>\n", "<result>\n", "Microsoft Corporation (MSFT) Stock Price, News, Quote & History - Yahoo ...\n", - "Find the latest Microsoft Corporation (MSFT) stock quote, history, news and other vital information to help you with your stock trading and investing.\n", + "Microsoft Corporation (MSFT) Stock Price, News, Quote & History - Yahoo Finance U.S. markets closed -4.31 Russell 2000 -7.29(-0.40%) (+0.05%) -2.80 HAPPENING SOON: Yahoo Finance breaks...\n", "</result>\n", "<result>\n", - "Microsoft Corporation (MSFT;) Stock Price, News, Quote & History ...\n", - "Microsoft Corporation (MSFT;) Stock Price, News, Quote & History - Yahoo Finance U.S. markets closed S&P 500 4,109.31 +58.48(+1.44%) Dow 30 33,274.15 +415.12(+1.26%) Nasdaq 12,221.91...\n", + "Microsoft Corporation (MSFT) Stock Price, Quote, News & History - Nasdaq\n", + "Microsoft Corporation Common Stock (MSFT) Stock Quotes - Nasdaq offers stock quotes & market activity data for US and global markets.\n", "</result>\n", - "<|im_end|>assistantThe current stock price for Microsoft Corp (MSFT) is not available in the provided search results. Please note that stock prices are constantly changing, and it's best to check a reliable financial website or app for the most up-to-date information.\n", + "assistantMicrosoft's stock price is currently $288.37. Please note that stock prices are constantly changing, so it's best to check an updated source for the most accurate information.systemYou are a helpful assistant.userFrom now on, whenever your response depends on any factual information, please search the web by using the function <search>query</search> before responding. I will then paste web results in, and you can respond.assistantOk, I will do that. Let's do a practice rounduserWho are the founders of OpenAI?assistant<search>OpenAI founders</search>userSearch results:\n", + "systemYou are a helpful assistant.userFrom now on, whenever your response depends on any factual information, please search the web by using the function <search>query</search> before responding. I will then paste web results in, and you can respond.assistantOk, I will do that. Let's do a practice rounduserWho are the founders of OpenAI?assistant<search>OpenAI founders</search>userSearch results:\n", "<result>\n", "OpenAI - Wikipedia\n", "OpenAI systems run on the fifth most powerful supercomputer in the world. [5] [6] [7] The organization was founded in San Francisco in 2015 by Sam Altman, Reid Hoffman, Jessica Livingston, Elon Musk, Ilya Sutskever, Peter Thiel and others, [8] [1] [9] who collectively pledged US$ 1 billion. Musk resigned from the board in 2018 but remained a donor.\n", @@ -811,8 +819,9 @@ "Sam Altman - Wikipedia\n", "Samuel H. Altman ( / ˈɔːltmən / AWLT-mən; born April 22, 1985) is an American entrepreneur, investor, and programmer. [2] He is the CEO of OpenAI and the former president of Y Combinator. [3] [4] Altman is also the co-founder of Loopt (founded in 2005) and Worldcoin (founded in 2020). Early life and education [ edit]\n", "</result>assistantThe founders of OpenAI are Sam Altman, Reid Hoffman, Jessica Livingston, Elon Musk, Ilya Sutskever, Peter Thiel and others.userThat was great, now let's do another one.assistantOk, I'm ready.userWho is Marco Tulio Ribeiro?\n", + "assistant<search>Marco Tulio Ribeiro</search>\n", + "" ] }, "metadata": {}, @@ -875,13 +881,13 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "assistant<search>Marco Tulio Ribeiro</search>\n", - "<|im_start|>user\n", - "Search results:\n", - "" + "userSearch results: Marco Tulio Ribeiro - Google Scholar\n", - "Marco Tulio Ribeiro. Microsoft Research. Verified email at cs.washington.edu - Homepage. Machine Learning Natural Language Processing. Articles Cited by Public access Co-authors. Title. ... MT Ribeiro, N Ziviani, ESD Moura, I Hata, A Lacerda, A Veloso. ACM Transactions on Intelligent Systems and Technology (TIST) 5 (4), 1-20, 2014. 133:\n", + "Marco Tulio Ribeiro. Microsoft Research. Verified email at cs.washington.edu - Homepage. Machine Learning Natural Language Processing. Articles Cited by Public access Co-authors. Title. ... MT Ribeiro, N Ziviani, ESD Moura, I Hata, A Lacerda, A Veloso. ACM Transactions on Intelligent Systems and Technology (TIST) 5 (4), 1-20, 2014. 134:\n", "</result>\n", - "<|im_end|>assistantMarco Tulio Ribeiro is a researcher at Microsoft Research in the Adaptive Systems and Interaction group. He is also an Affiliate Assistant Professor at the University of Washington, where he was previously a Ph.D. student advised by Carlos Guestrin and Sameer Singh. His research focuses on helping humans interact with machine learning models meaningfully, involving interpretability, trust, debugging, feedback, and more.systemYou are a helpful assistant.userFrom now on, whenever your response depends on any factual information, please search the web by using the function <search>query</search> before responding. I will then paste web results in, and you can respond.assistantOk, I will do that. Let's do a practice rounduserWho are the founders of OpenAI?assistant<search>OpenAI founders</search>userSearch results:\n", + "systemYou are a helpful assistant.userFrom now on, whenever your response depends on any factual information, please search the web by using the function <search>query</search> before responding. I will then paste web results in, and you can respond.assistantOk, I will do that. Let's do a practice rounduserWho are the founders of OpenAI?assistant<search>OpenAI founders</search>userSearch results:\n", "<result>\n", "OpenAI - Wikipedia\n", "OpenAI systems run on the fifth most powerful supercomputer in the world. [5] [6] [7] The organization was founded in San Francisco in 2015 by Sam Altman, Reid Hoffman, Jessica Livingston, Elon Musk, Ilya Sutskever, Peter Thiel and others, [8] [1] [9] who collectively pledged US$ 1 billion. Musk resigned from the board in 2018 but remained a donor.\n", @@ -908,7 +914,7 @@ "{{gen "answer"}}\n", "{{~/assistant}}\n", "{{/if}}'>\n", - "" + "" ] }, "metadata": {}, @@ -918,16 +924,16 @@ "source": [ "query = \"What is 1+1?\"\n", "p3 = prompt(user_query=query)\n", - "p3\n", - "\n" + "p3\n" ] }, { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [], - "source": [] + "source": [ + "
\n", + "Have an idea for more helpful examples? Pull requests that add to this documentation notebook are encouraged!" + ] } ], "metadata": { @@ -946,7 +952,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.10.4" }, "orig_nbformat": 4 }, diff --git a/notebooks/guidance_acceleration.ipynb b/notebooks/guidance_acceleration.ipynb index 45d30c7e8..870fbfc92 100644 --- a/notebooks/guidance_acceleration.ipynb +++ b/notebooks/guidance_acceleration.ipynb @@ -89,11 +89,12 @@ ] }, { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [], - "source": [] + "source": [ + "
\n", + "Have an idea for more helpful examples? Pull requests that add to this documentation notebook are encouraged!" + ] } ], "metadata": { diff --git a/notebooks/pattern_guides.ipynb b/notebooks/pattern_guides.ipynb index 055cfe51a..73b3f3bd2 100644 --- a/notebooks/pattern_guides.ipynb +++ b/notebooks/pattern_guides.ipynb @@ -118,6 +118,14 @@ " verse=14\n", ")" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Have an idea for more helpful examples? Pull requests that add to this documentation notebook are encouraged!" + ] } ], "metadata": { diff --git a/notebooks/token_healing.ipynb b/notebooks/token_healing.ipynb index df1141ad1..c5010cab8 100644 --- a/notebooks/token_healing.ipynb +++ b/notebooks/token_healing.ipynb @@ -175,7 +175,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "
\n", + "
\n", "Have an idea for more helpful examples? Pull requests that add to this documentation notebook are encouraged!" ] }