CVC-LETTER / app.py
Yaroslav1234's picture
Update app.py
ef0b3ef
import random
import gradio as gr
import os
import sys
import json
import requests
import openai
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
openai.api_key = OPENAI_API_KEY
MODEL = "gpt-3.5-turbo"
DISABLED = False
NUM_THREADS = 8
def exception_handler(exception_type, exception, traceback):
print("%s: %s" % (exception_type.__name__, exception))
sys.excepthook = exception_handler
sys.tracebacklimit = 0
title = """<h1 align="center"><a href="https://www.federalregister.gov/documents/2023/03/09/2023-03681/safeguarding-advisory-client-assets">Safeguarding Advisory Client Assets</a></h1><h4 algin="center" style='text-align: center;'>A Proposed Rule by the Securities and Exchange Commission on 03/09/2023</h4>"""
if DISABLED:
title = """<h1 align="center" style="color:red">This app has reached OpenAI's usage limit. We are currently requesting an increase in our quota. Please check back in a few days.</h1>"""
# gr.themes.builder()
# theme = gr.themes.Default(primary_hue="green")
concerns = [
{"title": "Digital assets or crypto.", "content": "Digital assets like cryptocurrency, built on blockchain tech, transforming finance. Yet, regulatory uncertainties pose challenges. "},
{"title": "Impact on small businesses.", "content": "these reporting requirements will require small businesses and start up protocols who would not otherwise be required to track personal identifiable information to implement such tracking, which will cause expense to such businesses.These additional costs will put these projects at a disadvantage and could stifle innovation. "},
{"title": "Privacy.", "content": "Privacy and safety associated with allowing so many third parties to know my sensitive financial data and social security number."},
{"title": "Identify Theft.", "content": "The proposed regs will force many participants in DeFi to collect user information. This will cause sensitive taxpayer information to be stored without proper safeguards, and will encourage the creation of honey pots for identity theft under the guise of tax reporting."},
{"title": "Confusing.", "content": "The proposed regs create reporting requirements for too many different participants in DeFi. This will cause multiple, inconsistent, reports to be generated for the same transaction."},
{"title": "Too Sudden.", "content": "These proposed regs will come into effect before companies and protocols are able to accommodate them. Impact Abroad."},
{"title": "Impact Abroad.", "content": "The proposed regs do not sufficiently limit reporting requirements for protocols run outside the US, and for users outside the US."},
{"title": "Poorly defined terms.", "content": "The proposed regs use undefined terms, like platform, software and ledger, that are susceptible to many interpretations, and its definition of other terms, like wallet and validator, are defined in ways that do not describe their technical meaning. This will lead to confusion."}
]
topIssue = [
"Privacy Concerns (The proposal may compromise the privacy of individuals engaging in legitimate transactions involving digital assets, potentially leading to data breaches and misuse of personal information.)",
"Technological Limitations (The proposal may not adequately account for the evolving nature of blockchain technology and the challenges associated with identifying specific transactions involving digital assets.)",
"Ineffective Deterrence (The proposed measures may not effectively deter money laundering activities involving digital assets, as illicit actors may find alternative methods to obfuscate their transactions.)",
"Regulatory Overreach (The proposal may exceed the regulatory authority granted to FinCEN, potentially infringing on the jurisdiction of other regulatory bodies and creating confusion and overlap in compliance requirements.)",
"Impact on Innovation (The proposal may stifle innovation in the digital asset industry by imposing burdensome regulations that hinder the development and adoption of new technologies.)",
"Potential for Regulatory Arbitrage (The proposal may incentivize individuals and businesses to relocate to jurisdictions with more favorable regulatory environments, leading to the loss of talent and economic activity in the United States.)",
"Disincentive for Compliance (The proposed reporting and recordkeeping requirements may create a disincentive for compliant actors to engage in digital asset transactions, leading to a decrease in legitimate economic activity.)",
"Increased Compliance Costs (The proposal may place a significant financial burden on financial institutions and businesses involved in digital asset transactions, potentially leading to higher fees and costs for consumers.)",
"Burden on Small Businesses (The proposed regulations may disproportionately impact small businesses in the digital asset industry, as they may lack the resources and expertise to comply with the increased reporting and recordkeeping requirements.)",
"Lack of Global Harmonization (The proposal may not align with international regulations and standards for digital assets, potentially creating inconsistencies and conflicts in compliance requirements.)",
"Negative Impact on Financial Inclusion (The proposal may hinder financial inclusion efforts by imposing barriers and restrictions on individuals and businesses seeking to access digital asset services.)",
"Disruption to Cryptocurrency Exchanges (The proposed regulations may disrupt the operations of cryptocurrency exchanges, potentially leading to decreased liquidity and trading activity.)",
"businesses at a competitive disadvantage compared to their international counterparts, who may operate in jurisdictions with more favorable regulatory frameworks.)",
"Liability Concerns (Financial institutions and businesses may face increased legal and regulatory liability for failing to comply with the proposed requirements, leading to potential lawsuits and reputational damage.)",
"Inadequate Guidance and Clarity (The proposal may lack clear guidelines and definitions, leading to confusion and subjective interpretations when it comes to compliance.)",
"Limited Enforcement Resources (FinCEN may not have sufficient resources and capacity to effectively enforce the proposed regulations, potentially undermining the intended impact on money laundering activities.)",
"Risk of Regulatory Capture (The proposal may be susceptible to regulatory capture, where the interests of certain stakeholders influence the formulation and implementation of the regulations.)",
"Negative Perception of Digital Assets (The proposal may reinforce negative perceptions and misconceptions about digital assets, potentially hindering their mainstream adoption and acceptance.)",
"Access to Financial Services (The proposal may limit access to financial services for individuals and businesses involved in legitimate digital asset activities, potentially exacerbating financial exclusion and inequality.)",
"Violation of Financial Privacy Rights (The proposal may infringe on individuals' financial privacy rights by requiring the disclosure of personal and transactional information without adequate justification or safeguards.)",
"Negative Impact on Market Stability (The proposal may introduce uncertainty and volatility into the digital asset market, potentially leading to price fluctuations and decreased investor confidence.)",
"Detrimental to the U.S. Digital Asset Industry (The proposed regulations may undermine the growth and development of the U.S. digital asset industry, potentially pushing innovative projects and businesses to more accommodating jurisdictions.)",
"Overemphasis on Money Laundering Risks (The proposal may disproportionately focus on money laundering risks associated with digital assets, neglecting other significant risks and benefits of the technology.)",
"Regulatory Compliance Barriers (The proposed regulations may create significant barriers to entry for new actors and startups in the digital asset industry, potentially stifling competition and innovation.)",
"Disproportionate Impact on Decentralized Exchanges (The proposal may disproportionately affect decentralized exchanges, which may struggle to comply with the stringent reporting and recordkeeping requirements.)",
"Impact on Cross-Border Transactions (The proposal may impose burdensome requirements on cross-border digital asset transactions, potentially hindering international trade and investment.)",
"Negative Perception of CVC Mixing (The proposal may perpetuate the association of CVC mixing with illicit activities, potentially hindering legitimate use cases and innovation in privacy-preserving technologies.)",
"Limited Law Enforcement Benefits (The proposed regulations may not provide significant additional benefits to law enforcement agencies in combating money laundering, as illicit actors may find alternative means to obfuscate their activities.)",
"Compliance Complexity (The proposal may introduce complex compliance requirements, potentially leading to confusion and errors in reporting and recordkeeping.)",
"Impact on Decentralized Finance (DeFi) (The proposal may impede the development and growth of decentralized finance applications, potentially limiting financial innovation and access for individuals.)",
"Disruption to Centralized Exchanges (The proposal may disrupt the operations of centralized exchanges, potentially leading to decreased trading volume and liquidity.)",
"Chilling Effect on Free Speech (The proposal may have a chilling effect on free speech and expression, as individuals may be deterred from engaging in certain transactions due to concerns about surveillance and scrutiny.)",
"Regulatory Uncertainty (The proposal may create regulatory uncertainty in the digital asset industry, potentially deterring investment and hindering the growth of the market.)",
"Negative Impact on Fintech Innovation (The proposal may discourage fintech innovation in the United States, as the regulatory burden and uncertainty may drive innovators to more favorable jurisdictions.)",
"Disincentive for Voluntary Compliance (The proposed regulations may create a disincentive for voluntary compliance, as compliant actors may face additional scrutiny and reporting requirements without significant benefits.)",
"Potential for Regulatory Capture by Special Interest Groups (The proposal may be susceptible to influence and capture by special interest groups, potentially leading to regulations that favor certain stakeholders over others.)",
"Compliance Duplications (The proposed regulations may duplicate existing anti-money laundering and counter-terrorism financing regulations, leading to increased compliance requirements and confusion for financial institutions.)",
"Negative Impact on Tokenization Efforts (The proposal may hinder the development and adoption of tokenization efforts, which have the potential to increase liquidity and accessibility of assets.)",
"Operational Complexity (The proposed regulations may introduce operational complexity for financial institutions, potentially requiring significant investments in systems and infrastructure to comply.)",
"Limited Scope of Proposal (The proposal may have a limited scope in addressing the broader challenges and risks associated with digital assets, potentially leaving significant vulnerabilities unaddressed.)",
"Potential for Regulatory Capture by Competitor Jurisdictions (The proposal may provide an opportunity for competitor jurisdictions to attract digital asset businesses and talent by offering more favorable regulatory environments.)",
"Negative Impact on Cryptocurrency Custodians (The proposal may impose additional reporting and compliance burdens on cryptocurrency custodians, potentially leading to increased costs and limitations on their services.)",
"Burden on Non-Financial Institutions (The proposed regulations may extend compliance requirements to non-financial institutions involved in digital asset transactions, potentially impacting a wide range of businesses and individuals.)",
"Negative Impact on Tokenized Securities (The proposal may create additional regulatory burdens for tokenized securities, potentially hindering the development and adoption of this innovative form of investment.)",
"Disruption to Stablecoin Ecosystem (The proposal may introduce uncertainty and disruption to the stablecoin ecosystem, potentially leading to decreased confidence and usage of these digital assets.)",
"Impact on Global Financial System (The proposal may have unintended consequences for the global financial system, as the increased regulatory burden on U.S. institutions may lead to changes in global financial flows.)",
"Difficulty in Implementing KYC (Know Your Customer) Procedures (The proposal may present challenges in implementing effective KYC procedures for digital asset transactions, potentially resulting in incomplete and inaccurate customer information.)",
"Negative Perception of Privacy-Preserving Technologies (The proposal may contribute to negative perceptions of privacy-preserving technologies, potentially hindering their adoption and development.)",
"Inadequate Cost-Benefit Analysis (The proposal may not adequately assess the costs and benefits associated with the proposed regulations, potentially resulting in an imbalance that outweighs the intended objectives.)",
"Disproportionate Reporting Burden on Exchanges (The proposal may place a disproportionate reporting burden on digital asset exchanges, potentially leading to increased operational costs and reduced competitiveness.)",
"Impact on Financial Innovation (The proposal may hinder financial innovation in the digital asset sector, potentially limiting opportunities for new and transformative business models.)",
"Difficulties in Compliance Monitoring (The proposal may pose challenges in effectively monitoring compliance with the proposed regulations, potentially undermining their effectiveness.)",
"Limited Resources for Training and Education (The proposal may strain the resources available for training and educating financial institution employees on the new compliance requirements.)",
"Negative Impact on Investor Protection (The proposal may undermine investor protection by creating barriers to accessing digital asset investment opportunities and services.)",
"Inadequate International Cooperation (The proposal may not foster sufficient international cooperation and coordination in combating money laundering and illicit activities involving digital assets.)",
"Potential for Discriminatory Practices (The proposal may inadvertently lead to discriminatory practices, as certain individuals or groups may face increased scrutiny and surveillance based on their digital asset transactions.)",
"Disruption to Tokenized Asset Offerings (The proposal may disrupt the tokenized asset offerings market, potentially limiting access to capital and investment opportunities for businesses and individuals.)",
"Negative Impact on Economic Growth (The proposal may stifle economic growth in the digital asset industry, potentially limiting job creation and innovation.)",
"Challenges in Defining CVC Mixing (The proposal may face challenges in adequately defining and identifying CVC mixing activities, potentially leading to ambiguity and inconsistency in implementation and compliance.)",
"Limitations on Financial Sector Competitiveness (The proposal may hinder the competitiveness of the U.S. financial sector in the global digital asset market, potentially leading to a loss of market share.)",
"Negative Impact on Pseudonymous Transactions (The proposal may discourage pseudonymous transactions in the digital asset space, potentially limiting individuals' ability to protect their financial privacy.)",
"Disproportionate Regulatory Burden on Individuals (The proposal may impose a disproportionate burden on individuals engaging in small-scale digital asset transactions, potentially discouraging their participation in the market.)",
"Impact on Decentralized Autonomous Organizations (DAOs) (The proposal may have unintended consequences for decentralized autonomous organizations, potentially impeding their ability to operate effectively.)",
"Inadequate Consultation with Stakeholders (The proposal may not have undergone sufficient consultation with stakeholders, potentially leading to a lack of understanding and support for the regulations.)",
"Negative Perception of CVC Mixing Services (The proposal may contribute to negative perceptions of CVC mixing services, potentially hindering legitimate use cases and innovation in privacy-enhancing technologies.)",
"Limited Effectiveness in Identifying Illicit Activities (The proposed regulations may not provide significant benefits in detecting and preventing illicit activities involving digital assets, as illicit actors may adapt their methods to evade detection.)",
"Potential for Capital Flight (The proposal may increase the risk of capital flight, as individuals and businesses may seek more favorable regulatory environments to conduct digital asset transactions.)",
"Harms to National Security (The proposal may inadvertently harm national security interests by impeding counterterrorism and intelligence efforts that rely on monitoring certain digital asset transactions.)",
"Negative Perception of Digital Asset Industry (The proposal may perpetuate negative perceptions of the digital asset industry, potentially hindering acceptance and integration into mainstream financial systems.)",
"Inadequate Guidance for Compliance (The proposal may not provide clear guidance and standards for financial institutions to comply with the recordkeeping and reporting requirements, leading to compliance challenges.)",
"Potential for Regulatory Capture by Law Enforcement Agencies (The proposal may be influenced by law enforcement agencies, potentially leading to regulations that prioritize investigative interests over the broader needs of the digital asset industry.)",
"Limited Resources for Regulatory Oversight (The proposal may strain regulatory resources available for oversight and enforcement, potentially hampering the effectiveness of the regulations.)",
"Negative Impact on Fungibility of Digital Assets (The proposal may impact the fungibility of digital assets, potentially leading to concerns about tainted assets and restricted liquidity.)",
"Disruption to Cross-Border Remittances (The proposal may introduce barriers and challenges to cross-border remittance services involving digital assets, potentially limiting access and increasing costs for individuals.)",
"Impact on Financial Empowerment (The proposal may hinder financial empowerment efforts, as individuals may face increased barriers and limitations in utilizing digital assets for financial purposes.)",
"Inadequate Cost Assessment for Compliance (The proposal may underestimate the costs associated with compliance for financial institutions, potentially leading to unanticipated financial burdens for businesses.)",
"Potential for Regulatory Capture by Financial Institutions (The proposal may be influenced by financial institutions, potentially resulting in regulations that favor their specific interests over the broader needs of the digital asset industry.)"
]
prompt = {
"issue": '',
"concern": '',
"system": 'Do not include a heading and do not mention about the PDF summary in the letter you return.5. Once you are done, you ask the user if there are any other areas of concern he or she has for you to craft a public comment. As well as offer it up to the user to ask any general questions that are part of the proposal.',
"content": """Here are some key points summarized for each subjects.
I. Statutory Provisions
Subject: Proposal for Special Measures on Convertible Virtual Currency Mixing for Anti-Money Laundering Purposes
Summary: The Financial Crimes Enforcement Network (FinCEN) is proposing a rule that would require domestic financial institutions and agencies to implement recordkeeping and reporting requirements for transactions involving convertible virtual currency (CVC) mixing. This proposal is based on section 311 of the USA PATRIOT Act, which grants the Secretary of the Treasury authority to impose special measures to combat money laundering and terrorist financing risks. The proposed rule aims to protect the U.S. financial system from these threats by imposing additional safeguards on covered institutions.
II. Summary of NPRM
Subject: Proposal to regulate transactions involving Convertible Virtual Currency (CVC) mixing
Summary: The Financial Crimes Enforcement Network (FinCEN) is proposing a rule that requires domestic financial institutions to implement recordkeeping and reporting requirements for transactions involving CVC mixing. CVC mixing involves making CVC transactions untraceable and anonymous, making it attractive to illicit foreign actors. The proposed rule aims to mitigate money laundering risks associated with CVC mixing by increasing transparency and assisting law enforcement in identifying and prosecuting illegal activities.
III. Background
Subject: Proposal to Address Money Laundering Risks in Convertible Virtual Currency Mixing
Summary: The Financial Crimes Enforcement Network (FinCEN) has proposed a rule requiring domestic financial institutions and agencies to implement recordkeeping and reporting requirements for transactions involving convertible virtual currency (CVC) mixing. CVC mixing allows illicit actors to launder their funds and avoid detection by obfuscating their identities and the ownership of CVC. This poses a threat to anti-money laundering and countering the financing of terrorism regulations. The proposal aims to address the increasing use of CVC mixing by illicit actors, including cyber threat actors and darknet market participants, to transfer and launder their illicit proceeds. The need for action is highlighted by high-profile cases such as the Axie Infinity heist carried out by the DPRK-controlled Lazarus Group. CVC mixing is also commonly used to obfuscate the source of CVC obtained through ransomware attacks and darknet markets. The proposal seeks to enhance transparency and mitigate the risks associated with CVC mixing in order to combat money laundering.
IV. Finding That Transactions That Involve CVC Mixing Within or Involving a Jurisdiction Outside the United States Are a Class of Transactions of Primary Money Laundering Concern
Subject: Proposal to combat money laundering through CVC mixing
Summary: FinCEN is proposing recordkeeping and reporting requirements for domestic financial institutions and agencies involving transactions of convertible virtual currency (CVC) mixing. By increasing transparency and providing information for law enforcement, this measure aims to deter illicit actors, including cybercriminals and state-sponsored actors, from using CVC mixing services for money laundering and other financial crimes.
V. Proposed Enhanced Recordkeeping and Reporting by Covered Financial Institutions Where a Covered Financial Institution Knows, Suspects, or Has Reason To Suspect a Transaction Involves CVC Mixing Within or Involving a Jurisdiction Outside the United States
Subject: Proposed Enhanced Recordkeeping and Reporting for Transactions Involving Convertible Virtual Currency Mixing
Summary: FinCEN is proposing recordkeeping and reporting requirements for financial institutions to address the risks associated with convertible virtual currency (CVC) mixing. They have determined that these requirements are necessary to safeguard the U.S. financial system from illicit finance risks posed by CVC mixing. Other alternatives were considered but were deemed insufficient in collecting key information related to CVC transactions involving mixing. The proposed rule aims to mitigate risks, deter illicit actors, facilitate law enforcement investigations, and protect the U.S. financial system while preserving legitimate actors' ability to conduct secure and private financial transactions.
VI. Section-by-Section Analysis of Proposed Regulations
Subject: Proposed Regulations for Reporting and Recordkeeping of Convertible Virtual Currency Mixing
Summary: The proposed regulations require domestic financial institutions to implement recordkeeping and reporting requirements for transactions involving convertible virtual currency (CVC) mixing. The regulations aim to address the money laundering threat posed by CVC mixing by collecting information such as the amount of CVC transferred, CVC type, CVC mixer used, CVC wallet addresses, transaction hash, date of transaction, IP addresses, and customer information. Covered financial institutions would need to report this information to FinCEN within 30 days of detecting a covered transaction. Additionally, covered financial institutions must maintain records documenting compliance with the regulations.
VII. Request for Comments
Subject: Request for Comments on Proposed Rule for Convertible Virtual Currency Mixing
Summary: FinCEN is seeking public feedback on various aspects of the proposed rule for recordkeeping and reporting requirements related to transactions involving convertible virtual currency (CVC) mixing. The agency wants to ensure that the burden and impact of the rule are accurately assessed and considers potential alternatives to collecting information regarding CVC transactions. Additionally, FinCEN is interested in understanding the potential costs, particularly for small entities, and the impact on law enforcement's ability to track illicit activity. The agency is also open to suggestions for clarifying definitions and providing guidance to reduce compliance costs for financial institutions. Public comments should address these issues and provide supporting data or studies where possible.
VIII. Regulatory Impact Analysis
Subject: Regulatory Impact Analysis and Information Collection for Proposed Rule on Convertible Virtual Currency Mixing
Summary: The Financial Crimes Enforcement Network (FinCEN) is proposing a rule that would require domestic financial institutions and agencies to implement recordkeeping and reporting requirements for transactions involving convertible virtual currency (CVC) mixing. The proposed rule would be submitted to the Office of Management and Budget for review. FinCEN estimates that approximately 15,000 financial institutions would be affected, with an average annual burden of 98 hours per institution, resulting in a total annual burden of 1,470,000 hours. FinCEN is seeking public comments on the necessity and practicality of the proposed information collection, as well as ways to enhance the quality and minimize the burden of reporting.
"""
}
def predict(inputs, outputLength, concernDropdown, issueDropdown, name):
userPrompt="""
Create a draft public comment with no heading in response to the Proposal of Special Measure Regarding Convertible Virtual Currency Mixing, as a Class of Transactions of Primary Money Laundering Concern.
AGENCY:
Financial Crimes Enforcement Network (FinCEN), Treasury.
ACTION:
Notice of proposed rulemaking.
SUMMARY:
FinCEN is issuing a notice of proposed rulemaking (NPRM), pursuant to section 311 of the USA PATRIOT Act, that proposes requiring domestic financial institutions and domestic financial agencies to implement certain recordkeeping and reporting requirements relating to transactions involving convertible virtual currency (CVC) mixing.
Please mix and match concerns and issues, as well as quote any prior law as long as it is relevant. Make strong as well as nuanced points against the CVC rule proposals.
"""
userPrompt += prompt['content']
if issueDropdown:
userPrompt += " Focus my issues around the following:" + issueDropdown
if concernDropdown:
selected_concern = [item for item in concerns if item['title'] == concernDropdown]
if len(selected_concern) > 0:
userPrompt += " Focus my concerns around the following topics:" + selected_concern[0]['title'] + ' ' + selected_concern[0]['content']
if inputs:
userPrompt += "Here is my own concern:" + inputs
userPrompt += " The public comment should be about " + outputLength + " words."
userPrompt += " Please use name " + name + " in the letter."
messages=[
{"role": "system", "content": prompt['system']},
{"role": "user", "content": userPrompt}
]
m = ""
completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=messages,temperature=1.15, stream=True)
for chunk in completion:
if 'content' in chunk.choices[0].delta:
t = chunk.choices[0].delta.content
m += t
if t == '[' or t == 'Your' or t == ' Name' or t == ']':
print(t)
if '[Your Name]' in m:
m = m.replace('[Your Name]', name)
yield[['', m]]
else:
yield [['', m]]
def reset_textbox():
return gr.update(value='', interactive=False), gr.update(interactive=False)
def toneChange(tone):
if tone < 50:
return f"<h4 style='color: #1e6f1e'>Value:{tone} (Low Variance)</h4>"
elif tone < 80:
return f"<h4 style='color: #bf8d33'>Value:{tone} (Medium Variance)</h4>"
elif tone < 100:
return f"<h4 style='color: #bf3030'>Value:{tone} (~Spicy!)</h4>"
else:
return f"<h4 style='color: #bf3030'>Value:{tone} (Over-the-top [Not Recommended])</h4>"
def issueTopicChange(issue):
with gr.Group() as issueGroup:
for concern in topIssue:
gr.Checkbox(label=concern['title'], elem_classes="issue")
# return issueGroup
ic = []
cc = []
def updateComment(text, chatbot, name):
if len(text.split(' ')) < 5:
gr.Warning('Kindly provide a message that consists of a minimum of 10 words.')
return text, chatbot
if not chatbot or not chatbot[0][1]:
gr.Warning('First generate the letter and then type your message to update it')
return text, chatbot
userPrompt = prompt['content'] + prompt['issue'] + prompt['concern']
userPrompt += " And here is the draft letter. \n '''" + chatbot[0][1] + "'''"
userPrompt += " please modify the draft letter regarding bellow content. "
userPrompt += text
messages=[
{"role": "system", "content": prompt['system']},
{"role": "user", "content": userPrompt}
]
m = ""
completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=messages,temperature=1.15, stream=True)
for chunk in completion:
if 'content' in chunk.choices[0].delta:
t = chunk.choices[0].delta.content
m += t
if t == '[' or t == 'Your' or t == ' Name' or t == ']':
print(t)
if '[Your Name]' in m:
m = m.replace('[Your Name]', name)
yield '', [[text, m]]
else:
yield '', [[text, m]]
with gr.Blocks(theme=gr.themes.Default(spacing_size=gr.themes.sizes.spacing_lg, text_size=gr.themes.sizes.text_lg), css = """.gradio-container { max-width: 100% !important; width: 100%; margin: 0; } .issue { display: flex; flex-direction: column; } .issue>div {order: 2}
#chatbot {height: 520px; overflow: auto;}""") as demo:
concernInputs = []
with gr.Blocks() as concernBlock:
issueDropdown = gr.Dropdown(topIssue, label="Select an issue you want to address. (AI-generated)", info="")
for concern in concerns:
cc.append(concern['title'])
concernDropdown = gr.Dropdown(cc, label="Areas of concern (Human-generated)", info="")
txt = gr.Textbox(placeholder="Type your concern", label="Enter my own concern (optional) - Copy from the above lists")
outputLength = gr.Dropdown(
["300", "800", "1600"],
value="800",
label="Output letter length"
)
name = gr.Textbox(placeholder="Type your name", label="")
btn = gr.Button(value="Generate")
chatbot = gr.Chatbot(elem_id='chatbot',show_copy_button=True)
btn.click(predict, [txt, outputLength, concernDropdown, issueDropdown, name], [chatbot])
# with gr.Group(visible=True) as updateGroup:
u_txt = gr.Textbox(placeholder="", label='Further, customize your Public Comment (Optional). For instance, "Rewrite in a passive-aggressive tone" or "Infuse with some 4chan humor."')
u_btn = gr.Button(value="Send")
u_btn.click(updateComment, [u_txt, chatbot, name], [u_txt, chatbot])
demo.load(
None,
None,
_js="""
() => {
document.body.classList.remove('dark');
document.querySelector('gradio-app').style.backgroundColor = 'var(--color-background-primary)'
}
""",
)
demo.queue(max_size=20, concurrency_count=NUM_THREADS, api_open=False)
# demo.queue()
if __name__ == "__main__":
demo.launch(share=False)