{ "cells": [ { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "from langchain_openai import ChatOpenAI\n", "llm = ChatOpenAI()" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "from langchain.globals import set_verbose\n", "set_verbose(True)\n" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "AIMessage(content='Langsmith can help with testing in the following ways:\\n\\n1. Automated testing: Langsmith can help create automated test scripts that can be run repeatedly to check for bugs and errors in the software.\\n\\n2. Test case management: Langsmith can help manage and organize test cases, ensuring that all aspects of the software are properly tested.\\n\\n3. Performance testing: Langsmith can help with performance testing to ensure that the software meets the required performance standards.\\n\\n4. Security testing: Langsmith can help with security testing to identify vulnerabilities in the software and ensure that sensitive data is protected.\\n\\n5. Regression testing: Langsmith can help with regression testing to ensure that new code changes do not negatively impact existing functionality.\\n\\nOverall, Langsmith can provide expertise and tools to streamline the testing process and ensure that the software meets quality standards before release.')" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "llm.invoke(\"how can langsmith help with testing?\")" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "from langchain_core.prompts import ChatPromptTemplate\n", "prompt = ChatPromptTemplate.from_messages([\n", " (\"system\", \"You are world class technical documentation writer.\"),\n", " (\"user\", \"{input}\")\n", "])" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "from langchain_core.output_parsers import StrOutputParser\n", "\n", "output_parser = StrOutputParser()" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\"Langsmith, an advanced language generation model, can greatly assist with testing in various ways:\\n\\n1. Test Case Generation: Langsmith can generate a wide range of test cases automatically based on the given requirements or specifications. It can create diverse inputs, edge cases, and boundary conditions to ensure thorough test coverage.\\n\\n2. Test Data Generation: Langsmith can generate realistic and varied test data sets for testing different scenarios and conditions. This can help in validating the system's performance, scalability, and robustness.\\n\\n3. Test Scenario Simulation: Langsmith can simulate different test scenarios by generating natural language descriptions of user interactions, system responses, and expected outcomes. This can assist in creating comprehensive test scripts and scenarios.\\n\\n4. Test Report Generation: Langsmith can help in automating the generation of test reports by summarizing test results, highlighting issues, and providing insights into the overall test coverage and quality.\\n\\n5. Test Documentation: Langsmith can assist in creating detailed test documentation by generating test plans, test cases, test scripts, and other related materials in a clear and structured manner.\\n\\nOverall, Langsmith can streamline the testing process, improve test coverage, and enhance the quality of testing activities by leveraging its natural language generation capabilities.\"" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "chain = prompt | llm | output_parser\n", "\n", "chain.invoke({\"input\": \"how can langsmith help with testing?\"})" ] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.4" } }, "nbformat": 4, "nbformat_minor": 2 }