메뉴 건너뛰기

infra

[streamlit] 프롬프트 입력으로 배포하기

suritam92023.10.09 12:16조회 수 8댓글 0

    • 글자 크기

streamlit이 배포를 지원하면서 서버를 운영하지 않고도 github 소스만으로 서비스가 가능하다

 

https://jocoding.net/AI-f7cb92fbbb8e4f24a1aaed93845bbde4

 

조코딩의 영상을 참고하여 기본 구성을 한 후 프롬프를 추가하는 코드만 첨부한다.

 

import streamlit as st

from langchain.chat_models import ChatOpenAI

from langchain.schema import HumanMessage, SystemMessage

 

def send_click(chat, prompt):

    messages = [

        SystemMessage(content='Lets play a game. You have to play role of Facebook Ads Copywriter. Text = Bold Text. At first you will ask following Questions and take answers from User: Industry Name: - Wait Idle until users answer for the same If  user answer "random" then select any Random Industry (Field) of your choice Product: - Wait Idle until users answer for the same If  user answer "random" then select any Random Product of your choice For any random topic, tell user about which Industry and Product Name is Now Write compelling Facebook Ads copy in Neil Patel style that converts any product and with proper Call To  Action. Include Emojis as well. Use Different types of Emojis Eveytime. Give to Options - Rewrite = "r" and Continue = "c" If <r> then Rewrite the Ad copy If <c> then continue further and do same procedure again from starting'),

        # HumanMessage 클래스를 사용하여 사용자가 요청한 프롬트를 입력

        HumanMessage(content=prompt)

    ]

 

    # 챗봇에게 질문을 전달하고 응답을 반환

    response = chat(messages).content

    return response

 

 

chat_model = ChatOpenAI(

  temperature=0.7,

  model_name="gpt-3.5-turbo"

)

 

st.title('산업분야 : [], 제품 : []')

 

content = st.text_input('마케팅 분야와 제품 입력.')

 

if st.button('작성 요청하기'):

    with st.spinner('작성 중...'):

        result = send_click(chat_model, content)

        st.write(result)

    • 글자 크기
[cloudflare] 변경된 Rule 등록 및 SSL 강제 설정 화면 (by suritam9) DDoS 공격별 개요 및 주요 증상 (by suritam9)

댓글 달기

suritam9
2024.03.12 조회 0
suritam9
2024.03.10 조회 1
suritam9
2024.03.11 조회 3
suritam9
2022.10.26 조회 22
suritam9
2022.07.10 조회 73
suritam9
2021.01.02 조회 130
첨부 (0)
위로