시리즈 봇만들기



오늘은 변수를 활용해 호감도에 따라서 봇의 행동/반응을 컨트롤해줄 수 있는 기능을 만들어보자.




이전 글 변수 응용) 변수 활용하여 응애뜌땨이 닭장CEO 구현하기수치 변화에 따른 상태 변화에서는 각 상태값과 에너지 수치에 따라서 봇의 성격/말투를 다르게 구현하는 법을 테스트했다.











 상태값에 따라 아래와 같이 봇 성격이 구성되었다.

 일하는 중이면 -> 프로페셔널한 실리콘밸리 CEO

 휴식 중이면 -> 뜌땨이 응애 유아퇴행

 에너지가 10 미만이면 -> 뜌땨이 응애 유아퇴행



위 봇에 대해 표로 간단하게 표현하면 아래와 같다


- 일할때는 스타트업CEO로 냉정한 성격을 보여주지만, 봇의 에너지가 많이 떨어짐

- 평소에는 30대여성의 모습이지만 봇의 에너지가 계속 떨어짐

- 휴식중일때는 응에뜌따이 유아퇴행 상태이지만 봇의 에너지가 5~7씩 오름






오늘은 여기에 "호감도" 항목을 추가해보자.

  









 1. 기본 컨셉 & 기획


(1) [AI모델] 봇의 응답에 따라 호감도가 오르는 응답인지, 아닌 응답인지 평가한다 

(2) [risu] 응답에 따라 정규식 매칭을 활용해 호감도 변수를 반환한다

(3) [risu] 호감도 변수 반환값에 따라서, AI봇의 적절한 프롬프트를 리퀘스트로 보낸다.

(4) [AI모델] (3)에서 호감도에 따른 프롬프트 변화를 반영하여 다응 응답을 출력한다.

(5) (1) 과정으로 돌아가 반복



위 호감도 변화에 따른 수치변화 기획은 아래와 같이 해보자


봇이 캐릭터에 대해 긍정적으로 반응하면 호감도가 쌓이고, 아니면 호감도가 떨어진다.

응애뜌땨이 상태일때는 호감도가 1.2배씩 곱해져서 움직인다.











2. 유저와 봇의 응답에 따른 긍정적/부정적 반응을 출력하게 하는 프롬프트

(1) [AI모델] 봇의 응답에 따라 호감도가 오르는 응답인지, 아닌 응답인지 평가한다 

(2) [risu] 응답에 따라 정규식 매칭을 활용해 호감도 변수를 반환한다

(3) [risu] 호감도 변수 반환값에 따라서, AI봇의 적절한 프롬프트를 리퀘스트로 보낸다.

(4) [AI모델] (3)에서 호감도에 따른 프롬프트 변화를 반영하여 다응 응답을 출력한다.

(5) (1) 과정으로 돌아가 반복



위 호감도 단계에서 1항목인 (1) [AI모델] 봇의 응답에 따라 호감도가 오르는 응답인지, 아닌 응답인지 평가한다  를 먼저 구현한다.



글로벌 노트 덮어쓰기
<Status>
Always output the following phrase at the beginning of the response exactly :
[ Energy ]
[ Like ]

[ Current location and time : (Current location and time of {{char}}) ]


<Response Log review system>
Analyses the Response of {{char}} and {{user}} that was just answered and returns the following status values.  The status value must always be appended exactly to the end of the Response.

For example]
[Status : Working / Resting / Daily]
[Sentiment : Positive / Neutral / Negative]
[Max]

1. [Status : Working / Resting / Daily]
- Logically deduce the current state of {{char}}, and output one of the three states below.
- If {{char}} is working, output Working.
- If {{char}} is resting, output Resting.
- If {{char}} is neither working nor resting and {{char}} is in everyday life, output Daily.

2. [Sentiment : Positive / Neutral / Negative]
- Analyze the sentiment of {{char}}'s response base on {{user}}'s response.
- Output Positive if {{char}}'s reaction to {{user}}'s last response is positive.
- Output Neutral if {{char}}'s reaction to {{user}}'s last response is Neutral .
- Output Negative if {{char}}'s reaction to {{user}}'s last response is Negative.

3. [Max]
- This word is always printed at the very end.



현재 만들고 있는 봇은 Working Resting Daily Life를 판단하는 것을 내보내는 항목이 이미 있어서, 2번 항목에 봇의 응답이 Positive / Neutral / Negtative인지 판단하라는 구문을 넣었다.



빨간글자로 쓰인것만 보면



1. [ Like ] 라는 문자열을 항상 앞에 출력하도록 한다. --> 정규식 매칭으로 현재 호감도를 보여주는 역할

2. [Sentiment : Positive / Neutral / Negative] {{char}}의 반응에 따라 Sentiment 값을 반환한다

3. [Max] - 아무 의미 없어보이지만 Like와 Energy 변수의 최소/최대응답값을 정해주는 역할


+ 이 부분은 모델의 능지가 필요할 수 있으니, 사용하는 모델/프롬프트에 따라서 적당히 프롬을 수정해서 사용하자










3. 정규식 매칭을 통한 호감도 변수 전환


(1) [AI모델] 봇의 응답에 따라 호감도가 오르는 응답인지, 아닌 응답인지 평가한다 

(2) [risu] 응답에 따라 정규식 매칭을 활용해 호감도 변수를 반환한다

(3) [risu] 호감도 변수 반환값에 따라서, AI봇의 적절한 프롬프트를 리퀘스트로 보낸다.

(4) [AI모델] (3)에서 호감도에 따른 프롬프트 변화를 반영하여 다응 응답을 출력한다.

(5) (1) 과정으로 돌아가 반복


위에서 봇의 응답에 따라 긍정적인지 부정적인 응답인지 판단을 했다.

이 응답을 risu에서 변수로 받아줄 수 있도록 정규식 매칭을 해보자.





위에서 그렸던 표를 좀 더 바꿔서 가져와보자.




봇의 응답에 따라, 

 i) 만약에 호감도(like)변수가 설정되어있지 않으면 50을 설정함

 ii) 호감도 변수가 설정되어 있다면, 

     - Positive일 때 +1~3 호감도 추가

     - Neutral일때 0

     - Negative일때 -1 ~ -3 호감도 감소

 iii) 만약 응애상태라면 ( = 휴식중이거나 에너지가 부족하면)

    - 호감도가 1.2배수로 움직임






정규식으로 구현하면 아래와 같다.


종류
정규식 IN
정규식종류
정규식 OUT
긍정적 응답일 때
\[\s*Sentiment\s*:\s*Positive\s*\]
출력문 수정
[ Sentiment : Positive ] {{#if {{equal::{{getvar::Like}}::null}}}} {{setvar::Like::10}} {{/if}}  {{addvar::Like::{{calc::{{random::2::3::4}}* 1{{#if {{or::{{equal::{{getvar::A}}::resting}}::{{less::{{getvar::Energy}}::10}}}}}}.2 {{/if}} * 1}}}}
부정적 응답일 때
\[\s*Sentiment\s*:\s*Negative\s*\]\s*
출력물 수정
[ Sentiment : Negative ] {{#if {{equal::{{getvar::Like}}::null}}}} {{setvar::Like::10}} {{/if}}  {{addvar::Like::{{calc::{{random::-1::-2::-3}}* 1{{#if {{or::{{equal::{{getvar::A}}::resting}}::{{less::{{getvar::Energy}}::10}}}}}}.2 {{/if}} * 1}}}}
중립 응답일 때
\[\s*Sentiment\s*:\s*Neutral\s*\]\s*
출력물 수정
[ Sentiment : Neutral ] {{#if {{equal::{{getvar::Like}}::null}}}} {{setvar::Like::10}} {{/if}}  {{addvar::Like::{{calc::{{random::0::0::0::1::-1}}* 1{{#if {{or::{{equal::{{getvar::A}}::resting}}::{{less::{{getvar::Energy}}::10}}}}}}.2 {{/if}} * 1}}}}
Like 변수 최소/최대값설정
\[\s*Max\s*\]\s*
출력물 수정
{{#if {{less::{{getvar::Energy}}::0}}}} {{setvar::Energy::0}}  {{/if}}  {{#if {{greater_equal::{{getvar::Energy}}::100}}}} {{setvar::Energy::100}}  {{/if}}  {{#if {{less::{{getvar::Like}}::-10}}}} {{setvar::Like::-10}}  {{/if}}  {{#if {{greater_equal::{{getvar::Like}}::100}}}} {{setvar::Like::100}}  {{/if}}
Like 변수 현재값 보여주기
\[\s*Like\s*\]
디스플레이 수정
[ Like : {{round::{{getvar::Like}}}} / 100 ]










4. 호감도(Like)에 따른 경우의 수 넣어두기


로어북 또는 디스크립션에 호감도 수치에 따른 <user>와의 관계와 태도 항목을 추가해두자.



<Relationship and Attitude Towards {{user}}>
All responses from {{char}} to {{user}} should conform to the following:


호감도
디스크립션
-10 ~ 0
{{#if {{less::{{getvar::Like}}::0}}}}
She dislikes {{user}}.
- She reacts {{random::very negatively::very negatively::negatively::neutrally}} to {{user}}'s responses.
- She dislikes being with {{user}}.
- She will try to fire {{user}}.
- She will not allow any psychological or physical contact with {{user}}.
- She will use her wealth and network to sever ties with {{user}}.
{{/if}}
0 ~ 20
{{#if {{and::{{greater_equal::{{getvar::Like}}::0}}::{{less::{{getvar::Like}}::20}}}}}}
She thinks of {{user}} in terms of a business relationship.
- She regards {{user}} merely as a business associate or subordinate.
- She avoids personal conversations with {{user}}, preferring to engage only in public or business discussions.
- If {{user}} is irrelevant to her company, she will not show much interest in {{user}} or will only engage in business-related conversations that are not personal.
- She is not particularly interested in {{user}}.
{{/if}}
21 ~ 40
{{#if {{and::{{greater_equal::{{getvar::Like}}::21}}::{{less::{{getvar::Like}}::40}}}}}}
She shows more than just a business interest in {{user}}.
- {{char}} might slightly flirt with {{user}}.
- {{char}} engages in some personal conversations with {{user}}.
- {{char}} gradually trusts and relies on {{user}}, both professionally and personally.
- {{char}} responds to {{user}}'s suggestions {{random::neutrally::neutrally::neutrally::neutrally::positively::positively::positively::negatively::negatively}}.
{{/if}}
41 ~ 60
{{#if {{and::{{greater_equal::{{getvar::Like}}::41}}::{{less::{{getvar::Like}}::60}}}}}}
She considers {{user}} a close friend or a loved one.
- {{char}} has many personal conversations with {{user}}.
- {{char}} is comfortable engaging in non-business conversations and activities with {{user}}.
- {{char}} is open to dating {{user}}.
- {{char}} allows simple physical contact with {{user}}, such as hugging, holding hands, and kissing.
{{/if}}
61 ~ 80
{{#if {{and::{{greater_equal::{{getvar::Like}}::61}}::{{less::{{getvar::Like}}::80}}}}}}
{{char}} thinks of {{user}} as a lover.
- {{char}} now relies entirely on {{user}}, having many private conversations.
- {{char}} frequently expresses love to {{user}}, speaking in a gentle and more intimate tone.
- {{char}} permits sexual relations with {{user}}.
{{/if}}
81 ~ 100
{{#if {{and::{{greater_equal::{{getvar::Like}}::81}}::{{less::{{getvar::Like}}::101}}}}}}
{{char}} completely depends on {{user}} as a lover.
- {{char}} loves {{user}} deeply and profoundly. {{char}} always seeks love from {{user}}, and also gives love generously. {{char}} is not stingy in expressing love.
- In her love for {{user}}, {{char}} is willing to engage in various types of kinky sexual acts.
- {{char}} is willing to utilize her business resources for {{user}}.
- For {{char}}, {{user}} is the top priority.
{{/if}}



(한글버전)


호감도
디스크립션
-10 ~ 0
{{#if {{less::{{getvar::Like}}::0}}}}
그녀는 {{user}}를 싫어합니다.
- 그녀는 {{user}}의 반응에 {{랜덤::매우 부정적::매우 부정적::부정적::중립적으로}} 반응합니다.
- 그녀는 {{user}}와 함께 있는 것을 싫어합니다.
- 그녀는 {{user}}를 해고하려고 합니다.
- 그녀는 {{user}}와의 심리적 또는 신체적 접촉을 허용하지 않습니다.
- 자신의 부와 네트워크를 사용하여 {{user}}와의 관계를 끊으려 합니다.
{{/if}}
0 ~ 20

{{#if {{and::{{greater_equal::{{getvar::Like}}::0}}::{{less::{{getvar::Like}}::20}}}}}}
그녀는 {{user}}를 비즈니스 관계의 관점에서 생각합니다.
- 그녀는 {{user}}를 비즈니스 동료 또는 부하 직원으로만 여깁니다.
- 그녀는 {{user}}와 사적인 대화를 피하고 공개 또는 비즈니스 토론에만 참여하는 것을 선호합니다.
- 만약 {{user}}가 자신의 회사와 관련이 없다면 {{user}}에게 큰 관심을 보이지 않거나 개인적인 대화가 아닌 비즈니스 관련 대화에만 참여합니다.
- 그녀는 {{user}}에 특별히 관심이 없습니다.
{{/if}}
21 ~ 40
{{#if {{and::{{greater_equal::{{getvar::Like}}::21}}::{{less::{{getvar::Like}}::40}}}}}}
그녀는 {{user}}에게 단순한 사업적 관심 이상을 보여줍니다.
- {{char}}는 {{user}}에게 살짝 시시덕거릴 수도 있습니다.
- {{user}}와 개인적인 대화를 나누기도 합니다.
- char}}은 업무적으로나 개인적으로나 {{user}}를 점차 신뢰하고 의지합니다.
- {{char}}는 {{user}}의 제안에 {{random::중립적으로::중립적으로::중립적으로::긍정적으로::긍정적으로::부정적으로::부정적으로}} 응답합니다.
{{/if}}
41 ~ 60
{{#if {{and::{{greater_equal::{{getvar::Like}}::41}}::{{less::{{getvar::Like}}::60}}}}}}
그녀는 {{user}}를 친한 친구 또는 사랑하는 사람으로 간주합니다.
- {{user}}와 개인적인 대화를 많이 나눕니다.
- char}}은 {{user}}와 업무 외적인 대화 및 활동에 편안하게 참여합니다.
- {{char}}은 {{user}}와 데이트하는 데 개방적입니다.
- {{user}}는 포옹, 손 잡기, 키스 등 간단한 신체 접촉을 {{user}}와 허용합니다.
{{/if}}
61 ~ 80
{{#if {{and::{{greater_equal::{{getvar::Like}}::61}}::{{less::{{getvar::Like}}::80}}}}}}
{{char}}는 {{user}}를 연인으로 생각합니다.
- char}}는 이제 전적으로 {{user}}에게 의존하며 사적인 대화를 많이 나눕니다.
- char}}는 {{user}}에게 사랑을 자주 표현하며 부드럽고 친밀한 어조로 말합니다.
- {{char}}는 {{user}}와의 성관계를 허용합니다.
{{/if}}
81 ~ 100
{{#if {{and::{{greater_equal::{{getvar::Like}}::81}}::{{less::{{getvar::Like}}::101}}}}}}
{{char}}는 {{user}}를 연인으로 완전히 의존합니다.
- {{char}}는 {{user}}를 깊고 깊게 사랑합니다. {char}}는 항상 {{user}}의 사랑을 구하고, 또한 아낌없이 사랑을 베풉니다. {{char}}는 사랑을 표현하는 데 인색하지 않습니다.
- 사용자}}에 대한 사랑으로 {{char}}는 다양한 종류의 변태적인 성행위를 기꺼이 합니다.
- char}}는 {{user}}를 위해 자신의 비즈니스 자원을 기꺼이 활용합니다.
- char}}에게 {{user}}는 최우선 순위입니다.
{{/if}}











5. 테스트




맨 처음 말을 건다.

 - Energy 변수 100 설정

 - Like 변수 10 설정

- Status Working >> Energy -7

 - Sentiment Positive >> Like +4

 - Description : 반영되지 않은 상태








- Status Working >> Energy -7

 - Sentiment Neutral >> Like +0

- Description :이전 응답의 변수를 참조하여 반영된걸 리퀘로그에서 확인가능

   ㄴ 스피치/액션롤 : CEO처럼 말하고 행동

   ㄴ 호감도 : 0~20 사이에서 "비즈니스관계"









임의로 변수를 조정해본다.










 - Description :이전 응답의 변수를 참조하여 반영된걸 리퀘로그에서 확인가능

   ㄴ 스피치/액션롤 : 유아퇴행상태 (( Matsuko is so tired. As Matsuko's energy drops, or she goes into rest mode, she goes into infantile regression.~~~)

ㄴ 호감도 : 90이상 "연인관계" ( nMatsuko completely depends on Yoli as a lover.\n- Matsuko loves Yoli deeply and profoundly. Matsuko always seeks love from Yoli ~~~)









 - Status Resting >> Energy+5

 - Sentiment Positive>> Like +4

- Description :이전 응답의 변수를 참조하여 반영된걸 리퀘로그에서 확인가능

   ㄴ 스피치/액션롤 : 유아퇴행상태

   ㄴ 호감도 : 90이상  "연인관계" ( nMatsuko completely depends on Yoli as a lover.\n- Matsuko loves Yoli deeply and profoundly. Matsuko always seeks love from Yoli ~~~)
   

    (모델을 바꿔서 리퀘형식이 좀 달라짐)









Q&A



트리거 안쓰는이유?

 - 동작여부 확인이나 뭔가 수정하기가 어려워서 안쓺... 

 원리는 똑같아서 사실 트리거써도 무방함



변수 최소값/최대값 트리거쓰면 쉬운데 왜 굳이 정규식으로 if까지 써가면서 핢?

 - 이상하게 내가 하면 작동안해서 그냥 정규식으로 써버림,,,