implement diskcache (#39)

* chore: Add romeo runner

* fix: Linter

* wip

* wip dump

* chore: Update romeo parser

* chore: Anthropic model fix

* wip

* allbirds

* allbirds runner

* format

* wip

* wip

* mypy updates

* update

* remove r

* update tests

* format

* wip

* chore: Strategically update the message

* rebase and fix import issues

* Update package imports for graphiti_core in examples and utils

* nits

* chore: Update OpenAI GPT-4o model to gpt-4o-2024-08-06

* implement groq

* improvments & linting

* cleanup and nits

* Refactor package imports for graphiti_core in examples and utils

* Refactor package imports for graphiti_core in examples and utils

* implement diskcache

* remove debug stuff

* log cache hit when debugging only

* Improve LLM config. Fix bugs (#41)

Refactor LLMConfig class to allow None values for model and base_url

* chore: Resolve mc

---------

Co-authored-by: paulpaliychuk <pavlo.paliychuk.ca@gmail.com>
Co-authored-by: prestonrasmussen <prasmuss15@gmail.com>
This commit is contained in:
Daniel Chalef
2024-08-26 10:13:05 -07:00
committed by GitHub
parent 6e8c964aef
commit 895afc7be1
21 changed files with 12655 additions and 38 deletions

4
.gitignore vendored
View File

@@ -160,3 +160,7 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
.vscode/
## Other
# Cache files
cache.db*

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,53 @@
import os
import re
def sanitize_text(text):
# Remove special characters and extra whitespace
sanitized = re.sub(r'[^a-zA-Z0-9\s]', '', text)
sanitized = ' '.join(sanitized.split())
return sanitized
def parse_script(filename):
current_speaker = None
current_speech = []
messages = []
with open(filename, encoding='utf-8') as file:
for line in file:
line = line.strip()
# Check if this line is a new speaker
if (
line
and line.isupper()
and not line.startswith('ACT')
and not line.startswith('SCENE')
):
# If we have a current speaker, save their message
if current_speaker:
sanitized_speech = sanitize_text(' '.join(current_speech))
messages.append((sanitize_text(current_speaker), sanitized_speech))
# Start a new speech
current_speaker = line
current_speech = []
elif line and not line.startswith('[') and current_speaker:
# Add this line to the current speech
current_speech.append(line)
# Add the last speech
if current_speaker:
sanitized_speech = sanitize_text(' '.join(current_speech))
messages.append((sanitize_text(current_speaker), sanitized_speech))
return messages
def get_hamilton_messages():
file_path = 'hamilton.txt'
script_dir = os.path.dirname(__file__)
relative_path = os.path.join(script_dir, file_path)
# Use the function
return parse_script(relative_path)

View File

@@ -0,0 +1,83 @@
"""
Copyright 2024, Zep Software, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import asyncio
import logging
import os
import sys
from datetime import datetime, timedelta
from dotenv import load_dotenv
from examples.hamilton.hamilton_parser import get_hamilton_messages
from graphiti_core import Graphiti
from graphiti_core.llm_client import AnthropicClient
from graphiti_core.nodes import EpisodeType
from graphiti_core.utils.bulk_utils import RawEpisode
from graphiti_core.utils.maintenance.graph_data_operations import clear_data
load_dotenv()
neo4j_uri = os.environ.get('NEO4J_URI', 'bolt://localhost:7687')
neo4j_user = os.environ.get('NEO4J_USER', 'neo4j')
neo4j_password = os.environ.get('NEO4J_PASSWORD', 'password')
def setup_logging():
# Create a logger
logger = logging.getLogger()
logger.setLevel(logging.INFO) # Set the logging level to INFO
# Create console handler and set level to INFO
console_handler = logging.StreamHandler(sys.stdout)
console_handler.setLevel(logging.INFO)
# Create formatter
formatter = logging.Formatter('%(name)s - %(levelname)s - %(message)s')
# Add formatter to console handler
console_handler.setFormatter(formatter)
# Add console handler to logger
logger.addHandler(console_handler)
return logger
async def main():
setup_logging()
llm_client = AnthropicClient()
client = Graphiti(neo4j_uri, neo4j_user, neo4j_password, llm_client)
messages = get_hamilton_messages()
await clear_data(client.driver)
await client.build_indices_and_constraints()
episodes: list[RawEpisode] = [
RawEpisode(
name=f'Message {i}',
content=f'{speaker}: {speech}',
source_description='Hamilton Transcript',
source=EpisodeType.message,
reference_time=datetime.now() + timedelta(seconds=i * 10),
)
for i, (speaker, speech) in enumerate(messages[:50])
]
await client.add_episode_bulk(episodes)
asyncio.run(main())

View File

@@ -0,0 +1,339 @@
October 3, 2000
The First Gore-Bush Presidential Debate
MODERATOR: Good evening from the Clark Athletic Center at the University of Massachusetts in Boston. Im Jim Lehrer of the NewsHour on PBS, and I welcome you to the first of three 90-minute debates between the Democratic candidate for president, Vice President Al Gore and the Republican candidate, Governor George W. Bush of Texas. The debates are sponsored by the Commission on Presidential Debates and they will be conducted within formats and rules agreed to between the commission and the two campaigns. Well have the candidates at podiums. No answer to a question can exceed two minutes. Rebuttal is limited to one minute. But as moderator I have the option to follow up and to extend any particular give and take another three-and-a-half minutes. Even then, no single answer can exceed two minutes. The candidates under their rules may not question each other directly. There will be no opening statements, but each candidate may have up to two minutes for a closing statement. The questions and the subjects were chosen by me alone. I have told no one from the two campaigns, or the Commission, or anyone else involved what they are. There is a small audience in the hall tonight. They are not here to participate, only to listen. I have asked, and they have agreed, to remain silent for the next 90 minutes. Except for right now, when they will applaud as we welcome the two candidates, Governor Bush and Vice President Gore.
(Applause)
MODERATOR: And now the first question as determined by a flip of a coin, it goes to Vice President Gore. Vice President Gore, you have questioned whether Governor Bush has the experience to be President of the United States. What exactly do you mean?
GORE: Well, Jim, first of all, I would like to thank the sponsors of this debate and the people of Boston for hosting the debate. I would like to thank Governor Bush for participating, and I would like to say Im happy to be here with Tipper and our family. I have actually not questioned Governor Bushs experience. I have questioned his proposals. And here is why. I think this is a very important moment for our country. We have achieved extraordinary prosperity. And in this election, America has to make an important choice. Will we use our prosperity to enrich not just the few, but all of our families? I believe we have to make the right and responsible choices. If Im entrusted with the presidency, here are the choices that I will make. I will balance the budget every year. I will pay down the national debt. I will put Medicare and Social Security in a lockbox and protect them. And I will cut taxes for middle-class families. I believe its important to resist the temptation to squander our surplus. If we make the right choices, we can have a prosperity that endures and enriches all of our people. If Im entrusted with the presidency, I will help parents and strengthen families because, you know, if we have prosperity that grows and grows, we still wont be successful unless we strengthen families by, for example, ensuring that children can always go to schools that are safe. By giving parents the tools to protect their children against cultural pollution. I will make sure that we invest in our country and our families. And I mean investing in education, health care, the environment, and middle-class tax cuts and retirement security. That is my agenda and that is why I think that its not just a question of experience.
MODERATOR: Governor Bush, one minute rebuttal.
BUSH: Well, we do come from different places. I come from West Texas. The governor is the chief executive officer. We know how to set agendas. I think youll find the difference reflected in our budgets. I want to take one-half of the surplus and dedicate it to Social Security. One-quarter of the surplus for important projects, and I want to send one-quarter of the surplus back to the people who pay the bills. I want everybody who pays taxes to have their tax rates cut. And that stands in contrast to my worthy opponents plan, which will increase the size of government dramatically. His plan is three times larger than President Clintons proposed plan eight years ago. It is a plan that will have 200 new programs — expanded programs and creates 20,000 new bureaucrats. It it empowers Washington. Tonight you’re going to hear that my passion and my vision is to empower Americans to be able to make decisions for themselves in their own lives.
MODERATOR: So I take it by your answer, then, Mr. Vice President, that in an interview recently with the “New York Times” when you said that you questioned whether or not Governor Bush has experience enough to be president, you were talking about strictly policy differences.
GORE: Yes, Jim. I said that his tax cut plan, for example, raises the question of whether its the right choice for the country. And let me give you an example of what I mean. Under Governor Bushs tax cut proposal, he would spend more money on tax cuts for the wealthiest 1% than all of the new spending that he proposes for education, health care, prescription drugs and national defense all combined. Now, I think those are the wrong priorities. Now, under my proposal, for every dollar that I propose in spending for things like education and health care, I will put another dollar into middle class tax cuts. And for every dollar that I spend in those two categories, Ill put $2 toward paying down the national debt. I think its very important to keep the debt going down and completely eliminate it. And I also think its very important to go to the next stage of welfare reform. Our country has cut the welfare rolls in half. I fought hard from my days in the Senate and as vice president to cut the welfare rolls and weve moved millions of people in America into good jobs. But its now time for the next stage of welfare reform, and include fathers and not only mothers.
MODERATOR: Were going to get a lot of those.
BUSH: Let me just say that obviously tonight were going to hear some phony numbers about what I think and what we ought to do. People need to know that over the next ten years it is going to be $25 trillion of revenue that comes into our treasurey and we anticipate spending $21 trillion. And my plan say why dont we pass 1.3 trillion of that back to the people who pay the bills? Surely we can afford 5% of the $25 trillion that are coming into the treasury to the hard working people that pay the bills. There is a difference of opinion. My opponent thinks the government — the surplus is the governments money. Thats not what I think. I think its the hard-working people of Americas money and I want to share some of that money with you so you have more money to build and save and dream for your families. Its a difference of opinion. Its a difference between government making decisions for you and you getting more of your money to make decisions for yourself.
MODERATOR: Let me just follow up one quick question. When you hear Vice President Gore question your experience, do you read it the same way, that hes talking about policy differences only?
BUSH: Yes. I take him for his word. Look, I fully recognize Im not of Washington. Im from Texas. And hes got a lot of experience, but so do I. And Ive been the chief executive officer of the second biggest state in the union. I have a proud record of working with both Republicans and Democrats, which is what our nation needs. Somebody that can come to Washington and say lets forget all the finger pointing and get positive things done on Medicare, prescription drugs, Social Security, and so I take him for his word.
GORE: Jim, if I could just respond. I know that. The governor used the phrase phony numbers, but if you look at the plan and add the numbers up, these numbers are correct. He spends more money for tax cuts for the wealthiest 1% than all of his new spending proposals for health care, prescription drugs, education and national defense all combined. I agree that the surplus is the American peoples money, its your money. Thats why I dont think we should give nearly half of it to the wealthiest 1%, because the other 99% have had an awful lot to do with building the surplus in our prosperity.
MODERATOR: Three-and-a-half minutes is up. New question.
BUSH: I hope it’s about wealthy people.
MODERATOR: Governor Bush, you have a question. This is a companion question to the question I asked Vice President Gore. You have questioned whether Vice President Gore has demonstrated the leadership qualities necessary to be President of the United States. What do you mean by that?
BUSH: Actually what Ive said, Jim. Ive said that eight years ago they campaigned on prescription drugs for seniors. And four years ago they campaigned on getting prescription drugs for seniors. And now theyre campaigning on getting prescription drugs for seniors. It seems like they cant get it done. Now, they may blame other folks, but its time to get somebody in Washington who is going to work with both Republicans and Democrats to get some positive things done when it comes to our seniors. And so what Ive said is that theres been some missed opportunities. Theyve had a chance. Theyve had a chance to form consensus. Ive got a plan on Medicare, for example, thats a two-stage plan that says well have immediate help for seniors and what I call immediate Helping Hand, a $48 billion program. But I also want to say to seniors, if youre happy with Medicare the way it is, fine, you can stay in the program. But were going to give you additional choices like they give federal employees in the federal employee health plan. They have a variety of choices to choose, so should seniors. And my point has been, as opposed to politicizing an issue like Medicare, in other words, holding it up as an issue, hoping somebody bites it and try to clobber them over the head with it for political purposes, this year, in the year 2000, its time to get it done once and for all. Thats what Ive been critical about the administration for. Same with Social Security. I think there was a good opportunity to bring Republicans and Democrats together to reform the Social Security system so seniors will never go without. Those on Social Security today will have their promise made, but also to give younger workers the option at their choice of being able to manage some of their own money in the private sector to make sure theres a Social Security system around tomorrow. There are a lot of young workers at our rallies we go to that when they hear Ill trust them at their option to be able to manage, under certain guidelines, some of their own money to get a better rate of return so that theyll have a retirement plan in the future, they begin to nod their heads and they want a different attitude in Washington.
MODERATOR: One minute rebuttal.
GORE: Well, Jim, under my plan all seniors will get prescription drugs under Medicare. The governor has described Medicare as a government HMO. Its not, and let me explain the difference. Under the Medicare prescription drug proposal Im making, here is how it works, you go to your own doctor. Your doctor chooses your prescription. No HMO or insurance company can take those choices away from you. Then you go to your own pharmacy. You fill the prescription and Medicare pays half the cost. If youre in a very poor family or if you have very high costs, Medicare will pay all the costs, a $25 premium, and much better benefits than you can possibly find in the private sector. Now here is the contrast. 95% of all seniors would get no help whatsoever under my opponents plan for the first four or five years. Now, one thing I dont understand, Jim, is why is it that the wealthiest 1% get their tax cuts the first year, but 95% of seniors have to wait four to five years before they get a single penny?
BUSH: I guess my answer to that is the man is running on Medi-scare. Trying to frighten people in the voting booth. Its just not the way I think and its not my intentions and not my plan. I want all seniors to have prescription drugs in Medicare. We need to reform Medicare. There’s been opportunity to do so but this administration has failed to do it. And so seniors will have not only a Medicare plan where the poor seniors will have prescription drugs paid for, but there will be a variety of options. The current system today has meant a lot for a lot of seniors, and I really appreciate the intentions of the current system as I mentioned. If youre happy with the system you can stay in it. But there are a lot of procedures that havent kept up in Medicare with the current times. No prescription drug benefits, no drug therapy, no preventative medicines, no vision care. We need to have a modern system to help seniors, and the idea of supporting a federally controlled 132,000-page document bureaucracy as being a compassionate way for seniors, and the only compassionate source of care for seniors is not my vision. I believe we ought to give seniors more options. I believe we ought to make the system work better. I know this. I know it will require a different kind of leader to go to Washington to say to both Republicans and Democrats, lets come together. Youve had your chance, Vice President, youve been there for eight years and nothing has been done. My point is, is that my plan not only trusts seniors with options, my plan sets aside $3.4 trillion for Medicare over the next ten years. My plan also says it requires a new approach in Washington, D.C. Its going to require somebody who can work across the partisan divide.
GORE: If I could respond to that. Under my plan I will put Medicare in an iron clad lockbox and prevent the money from being used for anything other than Medicare. The governor has declined to endorse that idea even though the Republican as well as Democratic leaders in Congress have endorsed it. I would be interested to see if he would say this evening hell put Medicare in a lockbox. I don’t think he will because under his plan if you work out the numbers  $100 billion comes out of Medicare just for the wealthiest 1% in the tax cut. Now here is the difference. Some people who say the word reform actually mean cuts. Under the governors plan, if you kept the same fee for service that you have now under Medicare, your premiums would go up by between 18% and 47%, and that is the study of the Congressional plan that hes modeled his proposal on by the Medicare actuaries. Let me give you one quick example. There is a man here tonight named George McKinney from Milwaukee. Hes 70 years old, has high blood pressure, his wife has heart trouble. They have an income of $25,000 a year. They cant pay for their prescription drugs and so theyre some of the ones that go to Canada regularly in order to get their prescription drugs. Under my plan, half of their costs would be paid right away. Under Governor Bushs plan, they would get not one penny for four to five years and then they would be forced to go into an HMO or to an insurance company and ask them for coverage, but there would be no limit on the premiums or the deductibles or any of the terms and conditions.
BUSH: I cannot let this go by, the old-style Washington politics, of were going to scare you in the voting booth. Under my plan the man gets immediate help with prescription drugs. Its called Immediate Helping Hand. Instead of squabbling and finger pointing, he gets immediate help. Let me say something.
MODERATOR: Your –[cross talk]
GORE: Can I make another point? They get $25,000 a year income, that makes them ineligible.
BUSH: Look, this is a man who has great numbers. He talks about numbers. Im beginning to think not only did he invent the Internet, but he invented the calculator. Its fuzzy math. Its a scaring — hes trying to scare people in the voting booth. Under my tax plan that he continues to criticize, I set one-third. The federal government should take no more than a third of anybodys check. But I also dropped the bottom rate from 15% to 10%. Because by far the vast majority of the help goes to people at the bottom end of the economic ladder. If youre a family of four in Massachusetts, making $50,000, you get a 50% cut in the federal income taxes you pay. Its from $4000 to about $2000. Now, the difference in our plans is I want that $2,000 to go to you, and the vice president would like to be spending the $2,000 on your behalf.
MODERATOR: One quick thing, gentlemen. These are your rules. Im doing my best. Were way over the three and a half minutes. I have no problems with it. Do you want to have a quick response? Were almost to five minutes on this.
GORE: Its just clear you can go to the website and look. If you make more than $25,000 a year you dont get a penny of help under the Bush prescription drug proposal for at least four to five years, and then youre pushed into a Medicare — into an HMO or insurance company plan, and theres no limit on the premiums or the deductibles or any of the conditions. And the insurance companies say it wont work and they wont offer these plans.
MODERATOR: Let me ask you both this and well move on on the subject. As a practical matter, both of you want to bring prescription drugs to seniors, correct?
GORE: Correct.
BUSH: Correct.
GORE: The difference is I want to bring it to 100% and he wants to bring it to 5%.
BUSH: Thats totally false for him to stand up here and say that. Let me make sure the seniors hear me loud and clear. They have had their chance to get something done. Im going to work with Democrats and Republicans to reform the system. All seniors will be covered, all poor seniors will have their prescription drugs paid for, and in the meantime, well have a plan to help poor seniors and in the meantime it could be one year or two years.
GORE: Let me call your attention to the key word there. He said all poor seniors.
BUSH: Wait a minute. All seniors are covered under prescription drugs in my plan.
GORE: In the first year?
BUSH: If we can get it done in the first year, you bet. Yours is phased in in eight years.
GORE: Its a two-phase plan. For the first four years — it takes a year to pass it and for the first four years only the poor are covered. Middle class seniors like George McKinney and his wife are not covered for four to five years.
MODERATOR: I have an idea. If you have any more to say about this, you can say it in your closing statements and well move on, okay? New question. Vice President Gore. How would you contrast your approach to preventing future oil price and supply problems like we have now to the approach of Governor Bush?
GORE: Excellent question. And here is the simple difference. My plan has not only a short-term component, but also a long-term component. And it focuses not only on increasing the supply, which I think we have to do, but also on working on the consumption side. Now, in the short-term we have to free ourselves from the domination of the big oil companies that have the ability to manipulate the price from OPEC when they want to raise the price. And in the long-term we have to give new incentives for the development of domestic resources like deep gas in the western Gulf, like stripper wells for oil, but also renewable sources of energy. And domestic sources that are cleaner and better. And Im proposing a plan that will give tax credits and tax incentives for the rapid development of new kinds of cars and trucks and buses and factories and boilers and furnaces that dont have as much pollution, that dont burn as much energy, and that help us get out on the cutting edge of the new technologies that will create millions of new jobs. Because, when we sell these new products here, well then be able to sell them overseas. There is a ravenous demand for them overseas. Now, another big difference is Governor Bush is proposing to open up some of our most precious environmental treasures, like the Arctic National Wildlife Refuge for the big oil companies to go in and start producing oil there. I think that is the wrong choice. It would only give us a few months worth of oil and the oil wouldnt start flowing for many years into the future. I dont think its a fair price to pay to destroy precious parts of Americas environment. We have to bet on the future and move beyond the current technologies to have a whole new generation of more efficient, cleaner, energy technology.
BUSH: Its an issue I know a lot about. I was a small oil person for a while in west Texas. This is an administration thats had no plan. And all of a sudden the results of having no plan have caught up with America. First and foremost we have to fully fund LIHEAP which is a way to help low income folks, particularly here in the east to pay for high fuel bills. Secondly, we need an active exploration program in America. The only way to become less dependent on foreign sources of crude oil is to explore at home. You bet I want to open up a small part of Alaska. When that field is online it will produce one million barrels a day. Today we import one million barrels from Saddam Hussein. I would rather that a million come from our own hemisphere, our own country as opposed to Saddam Hussein. I want to build more pipelines to move natural gas throughout this hemisphere. I want to develop the coal resources in America. Have clean coal technologies. We’ve got abundant supplies of energy here in America and we’d better get after it, we better start exploring it or otherwise well be in deep trouble in the future because of our dependency upon foreign sources of crude.
MODERATOR: So if somebody is watching tonight and listening to what the two of you just said, is it fair to say, okay, the differences between Governor Bush and Vice President Gore are as follows. Youre for doing something on the consumption end and youre for doing something on the production end?
GORE: Let me clarify. Im for doing something both on the supply side and production side and on the consumption side. Let me say, that I found one thing in Governor Bushs answer that we certainly agree on, and thats the low income heating assistance program. I commend you for supporting that. I worked to get $400 million just a couple of weeks ago. And to establish a permanent home heating oil reserve here in the northeast. Now, as for the proposals that Ive worked for for renewables and conservation and efficiencies and new technologies. The fact is for the last few years in the Congress, weve faced a lot of opposition to them. Theyve only approved about 10% of the agenda Ive helped to send up there. I think we need to get serious about this energy crisis, both in the Congress and in the White House, and if you entrust me with the presidency, I will tackle this problem and focus on new technologies that will make us less dependent on big oil or foreign oil.
MODERATOR: How would you draw the difference?
BUSH: Well I would first say he should have been tackling it for the last seven years. Secondly the difference is we need to explore at home. And the vice president doesnt believe in exploration in Alaska. Theres a lot of shut-in gas that we need to be moving out of Alaska by pipeline. Theres an interesting issue up in the northwest as well. Do we remove dams that produce hydroelectric energy? Im against removing dams in the northwest. I don’t know where the vice president stands but that’s a renewable energy source of energy. We need to keep that in line. I was in coal country in West Virginia yesterday. There is an abundant supply of coal in America. I know we can do a better job of clean coal technologies. Im going to ask the Congress for $2 billion to make sure we have the cleanest coal technologies in the world. My answer to you is in the short-term we need to get after it here in America. We need to explore our resources and we need to develop our reservoirs of domestic production. We also need to have a hemispheric energy policy where Canada, Mexico and the United States come together. I brought this up recently with Vincent Fox the newly elected president in Mexico, hes a man I know from Mexico. I talked to him about how best to expedite the exploration of natural gas in Mexico and transport it up to the United States so we become less dependent on foreign sources of crude oil. This is a major problem facing America. The administration did not deal with it. Its time for a new administration to deal with the energy problem.
GORE: If I may just briefly, Jim, note. I found a couple of other things we agree upon. We may not find that many this evening, so I wanted to emphasize. I strongly support new investments in clean coal technology. I made a proposal three months ago on this. And also domestic exploration yes, but not in the environmental treasures of our country. We dont have to do that. Thats the wrong choice. I know the oil companies have been itching to do that, but it is not the right thing for the future.
BUSH: No. Its the right thing for the consumers. Less dependency upon foreign sources of crude is good for consumers. And we can do so in an environmentally friendly way.
GORE: Well can I have the last word on this?
MODERATOR: New question, new subject. Governor Bush. If elected president, would you try to overturn the FDAs approval last week of the abortion pill RU-486?
BUSH: I dont think a president can do that. I was disappointed in the ruling because I think abortions ought to be more rare in America, and Im worried that that pill will create more abortions and cause more people to have abortions. This is a very important topic and its a very sensitive topic, because a lot of good people disagree on the issue. I think what the next president ought to do is to promote a culture of life in America. Life of the elderly and life of those living all across the country. Life of the unborn. As a matter of fact, I think a noble goal for this country is that every child, born or unborn, need to be protected by law and welcomed to life. I know we need to change a lot of minds before we get there in America. What I do believe is that we can find good, common ground on issues of parental consent or parental notification. I know we need to ban partial birth abortions. This is a place where my opponent and I have strong disagreement. I believe banning partial birth abortions would be a positive step to reducing the number of abortions in America. This is an issue that will require a new attitude. Weve been battling over abortion for a long period of time. Surely this nation can come together to promote the value of life. Surely we can fight off these laws that will encourage doctors to — to allow doctors to take the lives of our seniors. Surely we can work together to create a cultural life so some of these youngsters who feel like they can take a neighbors life with a gun will understand that thats not the way America is meant to be. Surely we can find common ground to reduce the number of abortions in America. As to the drug itself, I mentioned I was disappointed. I hope the FDA took its time to make sure that American women will be safe who use this drug.
MODERATOR: Vice President Gore?
GORE: Well, Jim, the FDA took 12 years, and I do support that decision. They determined it was medically safe for the women who use that drug. This is indeed a very important issue. First of all on the issue of partial birth or so-called late-term abortion, I would sign a law banning that procedure, provided that doctors have the ability to save a womans life or to act if her health is severely at risk. Thats not the main issue. The main issue is whether or not the Roe v. Wade decision is going to be overturned. I support a womans right to choose. My opponent does not. It is important because the next president is going to appoint three and maybe even four justices of the Supreme Court. And Governor Bush has declared to the anti-choice groups that he will appoint justices in the mold of Scalia and Clarence Thomas, who are known for being the most vigorous opponents of a womans right to choose. Here is the difference. He trusts the government to order a woman to do what it thinks she ought to do. I trust women to make the decisions that affect their lives, their destinies and their bodies. And I think a womans right to choose ought to be protected and defended.
MODERATOR: Governor, well go to the Supreme Court question in a moment, but make sure I understand your position on RU-486. If youre elected president, not through appointments to the FDA, you wont support legislation to overturn this?
BUSH: I dont think a president can unilaterally overturn it. The FDA has made its decision.
MODERATOR: That means you wouldnt, through appointments, to the FDA and ask them to —
BUSH: I think once a decision has been made, its been made unless its proven to be unsafe to women.
GORE: Jim, the question you asked, if I heard you correctly, was would he support legislation to overturn it. And if I heard the statement day before yesterday, you said you would order — he said he would order his FDA appointee to review the decision. Now that sounds to me a little bit different. I just think that we ought to support the decision.
BUSH: I said I would make sure that women would be safe who used the drug.
MODERATOR: On the Supreme Court question. Should a voter assume — youre pro-life.
BUSH: I am pro-life.
MODERATOR: Should a voter assume that all judicial appointments you make to the supreme court or any other court, federal court, will also be pro-life?
BUSH: The voters should assume I have no litmus test on that issue or any other issue. Voters will know Ill put competent judges on the bench. People who will strictly interpret the Constitution and not use the bench to write social policy. That is going to be a big difference between my opponent and me. I believe that the judges ought not to take the place of the legislative branch of government. That theyre appointed for life and that they ought to look at the Constitution as sacred. They shouldnt misuse their bench. I dont believe in liberal activist judges. I believe in strict constructionists. Those are the kind of judges I will appoint. Ive named four supreme court justices in the State of Texas and would ask the people to check out their qualifications, their deliberations. Theyre good, solid men and women who have made good, sound judgments on behalf of the people of Texas.
MODERATOR: What kind of appointments should they expect from you?
GORE: We both use similar language to reach an exactly opposite outcome. I dont favor a litmus test, but I know that there are ways to assess how a potential justice interprets the Constitution. And in my view, the Constitution ought to be interpreted as a document that grows with our country and our history. And I believe, for example, that there is a right of privacy in the Fourth Amendment. And when the phrase a strict constructionist is used and when the names of Scalia and Thomas are used as the benchmarks for who would be appointed, those are code words, and nobody should mistake this, for saying the governor would appoint people who would overturn Roe v. Wade. Its very clear to me. I would appoint people that have a philosophy that I think would have it quite likely they would uphold Roe v. Wade.
MODERATOR: Is the vice president right? Is that a code word for overturning Roe v. Wade?
BUSH: It sounds like the vice president’s not right very many times tonight. I just told you the criteria on which Ill appoint judges. I have a record of appointing judges in the State of Texas. Thats what a governor gets to do. A governor gets to name supreme court judges. He also reads all kinds of things into my tax plan and into my Medicare plan. I want the viewers out there to listen to what I have to say about it.
MODERATOR: Reverse the question. What code phrases should we read by what you said about what kind of people you would appoint?
GORE: It would be likely that they would uphold Roe v. Wade. I do believe its wrong to use a litmus test. If you look at the history of a lower court judges rulings, you can get a pretty good idea of how theyll interpret questions. A lot of questions are first impression, and these questions that have been seen many times come up in a new context and so — but, you know, this is a very important issue. Because a lot of young women in this country take this right for granted and it could be lost. It is on the ballot in this election, make no mistake about it.
BUSH: Ill tell you what kind of judges hell put on. Hell put liberal activists justices who will use their bench to subvert the legislature, thats what hell do.
GORE: That’s not right.
MODERATOR: New subject, new question. Vice President Gore, if President Milosevic of Yugoslavia refuses to accept the election results and leave office, what action, if any, should the United States take to get him out of there?
GORE: Well, Milosevic has lost the election. His opponent, Kostunica, has won the election. Its overwhelming. Milosevics government refuses to release the vote count. Theres now a general strike going on. Theyre demonstrating. I think we should support the people of Serbia and Yugoslavia, as they call the Serbia plus Montenegro, and put pressure in every way possible to recognize the lawful outcome of the election. The people of Serbia have acted very bravely in kicking this guy out of office. Now he is trying to not release the votes and then go straight to a so-called runoff election without even announcing the results of the first vote. Now, weve made it clear, along with our allies, that when Milosevic leaves, then Serbia will be able to have a more normal relationship with the rest of the world. That is a very strong incentive that weve given them to do the right thing. Bear in mind also, Milosevic has been indicted as a war criminal and he should be held accountable for his actions. Now, we have to take measured steps because the sentiment within Serbia is, for understandable reasons, against the United States because their nationalism — even if they dont like Milosevic, they still have some feelings lingering from the NATO action there. So we have to be intelligent in the way we go about it. But make no mistake about it, we should do everything we can to see that the will of the Serbian people expressed in this extraordinary election is done. And I hope that hell be out of office very shortly.
MODERATOR: Governor Bush, one minute.
BUSH: Well, Im pleased with the results of the election. As the vice president is. Its time for the man to go. It means that the United States must have a strong diplomatic hand with our friends in NATO. Thats why its important to make sure our alliances are as strong as they possibly can be to keep the pressure on Mr. Milosevic. But this will be an interesting moment for the Russians to step up and lead as well. Be a wonderful time for the Russians to step into the Balkans and convince Mr. Milosevic that its in his best interest and his countrys best interest to leave office. The Russians have a lot of sway in that part of the world. We would like to see the Russians use that sway to encourage democracy to take hold. Its an encouraging election. Its time for the man to leave.
MODERATOR: What if he doesnt leave? What if all the diplomatic efforts, all the pressure from all over the world and he still doesnt go? Is this the kind of thing, to be specific, that you as president would consider the use of U.S. military force to get him gone?
GORE: In this particular situation, no. Bear in mind that we have a lot of sanctions in force against Serbia right now. And the people of Serbia know that they can escape all those sanctions if this guy is turned out of power. Now, I understand what the governor has said about asking the Russians to be involved, and under some circumstances that might be a good idea. But being as they have not yet been willing to recognize Kostunica as the lawful winner of the election, Im not sure its right for us to invite the president of Russia to mediate this — this dispute there because we might not like the results that comes out of that. They currently favor going forward with a runoff election. I think thats the wrong thing. I think the governors instinct is not necessarily bad because we have worked with the Russians in a constructive way in Kosovo, for example, to end the conflict there. But I think we need to be very careful in the present situation before we invite the Russians to play the lead role in mediating.
BUSH: Well obviously we wouldnt use the Russians if they didnt agree with our answer, Mr. Vice President.
GORE: They don’t.
BUSH: Let me say this to you, I wouldnt use force. I wouldnt use force.
MODERATOR: You wouldnt use force?
BUSH: No.
MODERATOR: Why not?
BUSH: Its not in our national interest to use force in this case. I would use pressure and diplomacy. There is a difference with what the president did in Kosovo which I supported and this. Its up to the people in this region to take control of their country.
MODERATOR: New question. How would you go about as president deciding when it was in the national interest to use U.S. force, generally?
BUSH: Well, if its in our vital national interests, and that means whether our territory is threatened or people could be harmed, whether or not the alliances are — our defense alliances are threatened, whether or not our friends in the Middle East are threatened. That would be a time to seriously consider the use of force. Secondly, whether or not the mission was clear. Whether or not it was a clear understanding as to what the mission would be. Thirdly, whether or not we were prepared and trained to win. Whether or not our forces were of high morale and high standing and well-equipped. And finally, whether or not there was an exit strategy. I would take the use of force very seriously. I would be guarded in my approach. I dont think we can be all things to all people in the world. I think weve got to be very careful when we commit our troops. The vice president and I have a disagreement about the use of troops. He believes in nation building. I would be very careful about using our troops as nation builders. I believe the role of the military is to fight and win war and therefore prevent war from happening in the first place. So I would take my responsibility seriously. And it starts with making sure we rebuild our military power. Morale in todays military is too low. Were having trouble meeting recruiting goals. We met the goals this year, but in the previous years we have not met recruiting goals. Some of our troops are not well-equipped. I believe were overextended in too many places. And therefore I want to rebuild the military power. It starts with a billion dollar pay raise for the men and women who wear the uniform. A billion dollars more than the president recently signed into law. Its to make sure our troops are well-housed and well-equipped. Bonus plans to keep some of our high-skilled folks in the services and a commander in chief who clearly sets the mission. The mission is to fight and win war and therefore prevent war from happening in the first place.
MODERATOR: Vice President Gore, one minute.
GORE: Let me tell you what I’ll do. First of all  I want to make it clear, our military is the strongest, best-trained, best-equipped, best-led fighting force in the world and in the history of the world. Nobody should have any doubt about that, least of all our adversaries or potential adversaries. If you entrust me with the presidency, I will do whatever is necessary in order to make sure our forces stay the strongest in the world. In fact, in my ten-year budget proposal Ive set aside more than twice as much for this purpose as Governor Bush has in his proposal. Now, I think we should be reluctant to get involved in someplace in a foreign country. But if our national security is at stake, if we have allies, if weve tried every other course, if were sure military action will succeed, and if the costs are proportionate to the benefits, we should get involved. Now, just because we dont want to get involved everywhere doesnt mean we should back off anywhere it comes up. I disagree with the proposal that maybe only when oil supplies are at stake that our national security is at risk. I think that there are situations like in Bosnia or Kosovo where theres a genocide, where our national security is at stake there.
BUSH: I agree our military is the strongest in the world today, thats not the question. The question is will it be the strongest in the years to come? The warning signs are real. Everywhere I go on the campaign trail I see moms and dads whose son or daughter may wear the uniform and they tell me about how discouraged their son or daughter may be. A recent poll was taken among 1,000 enlisted personnel, as well as officers, over half of whom will leave the service when their time of enlistment is up. The captains are leaving the service. There is a problem. And its going to require a new commander in chief to rebuild the military power. The other day I was honored to be flanked by Colin Powell and General Norman Schwartzkopf recently stood by me side and agreed with me. They said even if we are the strongest if we don’t do something if we dont have a clear vision of the military, if we dont stop extending our troops all around the world and nation building missions, then were going to have a serious problem coming down the road, and Im going to prevent that. Im going to rebuild our military power. Its one of the major priorities of my administration.
MODERATOR: Vice President Gore, how should the voters go about deciding which one of you is better suited to make the kinds of decisions, whether its Milosevic or whatever, in the military and foreign policy area?
GORE: Well, they should look at our proposals and look at us as people and make up their own minds. When I was a young man, I volunteered for the Army. I served my country in Vietnam. My father was a senator who strongly opposed the Vietnam War. I went to college in this great city, and most of my peers felt against the war as I did. But I went anyway because I knew if I didnt, somebody else in the small town of Carthage, Tennessee, would have to go in my place. I served for eight years in the House of Representatives and I served on the Intelligence Committee, specialized in looking at arms control. I served for eight years in the United States Senate and served on the Armed Services Committee. For the last eight years Ive served on the National Security Council, and when the conflict came up in Bosnia, I saw a genocide in the heart of Europe with the most violent war on the continent of Europe since World War II. Look, thats where World War I started in the Balkans. My uncle was a victim of poisonous gas there. Millions of Americans saw the results of that conflict. We have to be willing to make good, sound judgments. Incidentally, I know the value of making sure our troops have the latest technology. The governor has proposed skipping the next generation of weapons. I think thats a big mistake, because I think we have to stay at the cutting edge.
MODERATOR: Governor, how would you advise the voters to make the decision on this issue?
BUSH: I think youve got to look at how one has handled responsibility in office. Whether or not its — the same in domestic policy as well. Whether or not you have the capacity to convince people to follow? Whether or not one makes decisions based on sound principles or whether or not you rely upon polls and focus groups on how to decide what the course of action is. We have too much polling and focus groups going on in Washington today. We need decisions made on sound principles. Ive been the governor of a big state. I think one of the hallmarks of my relationship in Austin, Texas, is that Ive had the capacity to work with both Republicans and Democrats. I think thats an important part of leadership. I think what it means to build consensus. Ive shown I know how to do so. Tonight in the audience theres one elected state senator who is a Democrat, a former state-wide officer who is a Democrat, a lot of Democrats who are here in the debate to — because they want to show their support that shows I know how to lead. And so the fundamental answer to your question, who can lead and whos shown the ability to get things done?
GORE: If I could say one thing.
MODERATOR: We are way over three-and-a-half minutes. Go ahead.
GORE: One of the key points in foreign policy and national security policy is the need to re-establish the old-fashioned principle that politics ought to stop at the waters edge. When I was in the United States Congress, I worked with former President Reagan to modernize our strategic weaponry and to pursue arms control in a responsible way. When I was in the United States Senate I worked with former President Bush, your father. I was one of only a few Democrats in the Senate to support the Persian Gulf War. I think bipartisanship is a national asset. We have to find ways to reestablish it in foreign policy and national security policy.
MODERATOR: Do you have a problem with that?
BUSH: Yeah. Why havent they done it in seven years?
MODERATOR: New subject. New question. Should the voters of this election, Vice President Gore, see this in the domestic area as a major choice between competing political philosophies?
GORE: Oh, absolutely. This is a very important moment in the history of our country. Look, weve got the biggest surpluses in all of American history. The key question that has to be answered in this election is will we use that prosperity wisely in a way that benefits all of our people and doesnt go just to the few. Almost half of all the tax cut benefits, as I said under Governor Bushs plan, go to the wealthiest 1%. I think we have to make the right and responsible choices. I think we have to invest in education, protecting the environment, health care, a prescription drug benefit that goes to all seniors, not just to the poor, under Medicare, not relying on HMOs and insurance companies. I think that we have to help parents and strengthen families by dealing with the kind of inappropriate entertainment material that families are just heart sick that their children are exposed to. I think weve got to have welfare reform taken to the next stage. I think that we have got to balance the budget every single year, pay down the national debt and, in fact, under my proposal the national debt will be completely eliminated by the year 2012. I think we need to put Medicare and Social Security in a lockbox. The governor will not put Medicare in a lockbox. I dont think it should be used as a piggy bank for other programs. I think it needs to be moved out of the budget and protected. Ill veto anything that takes money out of Social Security or Medicare for anything other than Social Security or Medicare. Now, the priorities are just very different. Ill give you a couple of examples. For every new dollar that I propose for spending on health care, Governor Bush spends $3 for a tax cut for the wealthiest 1%. Now, for every dollar that I propose to spend on education, he spends $5 on a tax cut for the wealthiest 1%. Those are very clear differences.
MODERATOR: Governor, one minute.
BUSH: The man is practicing fuzzy math again. Theres differences. Under Vice President Gores plan, he is going to grow the federal government in the largest increase since Lyndon Baines Johnson in 1965. Were talking about a massive government, folks. Were talking about adding to or increasing 200 programs, 20,000 new bureaucrats. Imagine how many IRS agents it is going to take to be able to figure out his targeted tax cut for the middle class that excludes 50 million Americans. There is a huge difference in this campaign. He says hes going to give you tax cuts. 50 million of you wont receive it. He said in his speech he wants to make sure the right people get tax relief. Thats not the role of a president to decide right and wrong. Everybody who pays taxes ought to get tax relief. After my plan is in place, the wealthiest Americans will pay a higher percentage of taxes then they do today, the poorest of Americans, six million families, wont pay any tax at all. Its a huge difference. A difference between big exploding federal government that wants to think on your behalf and a plan that meets priorities and liberates working people to be able to make decisions on your own.
GORE: Let me just say, Jim, you havent heard the governor deny these numbers. Hes called them phony and fuzzy. The fact remains almost 30% of his proposed tax cut goes to — only to Americans that make more than $1 million per year. More money goes to the — can I have a rebuttal here?
MODERATOR: I want to see if he buys that.
BUSH: Let me tell you what the facts are. The facts are after my plan, the wealthiest of Americans pay more taxes of the percentage of the whole than they do today. Secondly, if youre a family of four making $50,000 in Massachusetts, you get a 50% tax cut. Let me give you one example. The Strunk family in Allentown, Pennsylvania, I campaigned with them the other day. They make $51,000 combined income, they pay about $3500 in taxes. Under my plan, they get $1800 of tax relief. Under Vice President Gores plan, they get $145 of tax relief. Now you tell me who stands on the side of the fence. You ask the Strunks whose plan makes more sense. There is a difference of opinion. He would rather spend the familys $1800 and I would rather the Strunks spend their own money.
MODERATOR: Do you see it that way Mr. Vice President?
GORE: No, I dont, and Im not going to go to calling names on his facts. Im just gonna tell you what the real facts are. The analysis that hes talking about leaves out more than half of the tax cuts that I have proposed. And if you just add the numbers up, he still hasnt denied it, he spends more money on a tax cut for the wealthiest 1% than all his new proposals for prescription drugs, healthcare, education, and national defense combined. Now those are the wrong priorities. $665 billion over ten years for the wealthiest 1%. As I said, almost 30% of it goes to Americans that make more than $1 million per year. Every middle class family is eligible for a tax cut under my proposal. Let me give you some specific examples. I believe college tuition up to $10,000 per year ought to be tax deductible so middle-class families can choose to send their children to college. I believe all senior citizens should be able to choose their own doctors and get prescription drugs from their own pharmacists with Medicare paying half the bill. I believe parents ought to be able to make more choices need more public and charter school choice to send their kids always to a safe school. We need to make education the number one priority in our country and treat teachers like the professionals that they are. And thats why I have made it a number one priority in my budget, not a tax cut for the wealthy.
BUSH: Let me talk about tax cuts one more time. This is a man whose plan excludes 50 million Americans.
GORE: Not so.
BUSH: Take for example the marriage penalty. If you itemize your tax return, you get no marriage penalty relief. He picks and chooses. He decides who the right people are. Its a fundamental difference of opinion. I want my fellow Americans to hear one more time. Well spend $25 trillion — well collect $25 trillion in revenue in the next 10 years and spend $21 trillion. Surely we can send 5% back to you that pay the bills. There’s a problem wait. I want to say something, Jim. This man has been disparaging my plan with all this Washington fuzzy math. I want you to hear a problem we’ve got here in the USA. If youre a single mother making $22,000 a year and you have two children, under this tax code, for every additional dollar you make, you pay a higher marginal rate on that dollar than someone making more than $200,000 a year, and that is not right. My plan drops the rate from 15% to 10% and increases the child credit from $500 to $1,000 to make the code more fair for everybody, not just a few, not just a handful. Everybody who pays taxes ought to get some relief.
MODERATOR: Having cleared that up, were going to a new question. Education. Governor Bush. Both of you have promised dramatically to change — to change dramatically public education in this country. Of the public money spent on education, only 6% of that is federal money. You want to change 100% of the public education with 6% of the money, is that possible?
BUSH: We can make a huge difference by saying if you receive federal money we expect you to show results. Let me give you a story about public education, if I might. Its about Kipp Academy in Houston, Texas. A charter school run by some people from Teach For America. Young folks saying Im going to do something good for my country. I want to teach. A guy named Michael runs the school. It is a school full of so-called at-risk children. Its how we unfortunately label certain children. Basically it means they cant learn. Its a school of strong discipline and high standards. Its one of the best schools in Houston. Here are the key ingredients. High expectations, strong accountabily. What Michael says, dont put all these rules on us, just let us teach and hold us accountable for every grade. Thats what we do. And as a result, these mainly Hispanic youngsters are some of the best learners in Houston, Texas. Thats my vision for public education all around America. Many of you viewers dont know, but Laura and I sent our girls to public school. They went to Austin High School. And many of the public schools are meeting the call. But, unfortunately, a lot of schools are trapping children in schools that just wont teach and wont change. Here is the role of the federal government. One is to change Head Start to a reading program. Two is to say if you want to access reading money, you can do so. The goal is for every single child to learn to Read. there must by K-2 diagnostic teaching tools, teacher training money, available. Three, we have to consolidate the federal programs to free districts to free the schools and encourage innovators like Michael. Let them reach out beyond the confines of the current structure to recruit teach-for-the-children type teachers. Four, were going to say if you receive federal money, measure third, fourth, fifth, sixth, seventh and eighth grade. Show us if they are learning to read, write, add and subtract and if so there will be bonus plans. But if not, instead of continuing to subsidize failure, the money will go to — the federal money will go to the parents for public school or charter school or tutorial or Catholic school. What I care about is children. And so does Michael Feinberg. And you know what? It can happen in America with the right kind of leadership.
GORE: We agree on a couple of things on education. I strongly support new accountability, so does Governor Bush. I strongly support local control, so does Governor Bush. Im in favor of testing as a way of measuring performance. Every school and every school district, have every state test the children. Ive also proposed a voluntary national test in the fourth grade and eighth grade, and a form of testing the governor has not endorsed. I think that all new teachers ought to be tested in the subjects that they teach. Weve got to recruit 100,000 new teachers. And I have budgeted for that. Weve got to reduce the class size so that the student who walks in has more one-on-one time with the teacher. We ought to have universal pre-school and we ought to make college tuition tax deductible, up to $10,000 a year. I would like to tell you a quick story. I got a letter today as I left Sarasota, Florida. Im here with a group of 13 people from around the country who helped me prepare. We had a great time. Two days ago we ate lunch at a restaurant. The guy that served us lunch gave me a letter today. His name is Randy Ellis. He has a 15-year-old daughter named Caley, who is in Sarasota High School. Her science class was supposed to be for 24 students. Shes the 36th student in that classroom. They sent me a picture of her in the classroom. They cant squeeze another desk in for her, so she has to stand during class. I want the federal government, consistent with local control and new accountability, to make improvement of our schools the number one priority so Caley will have a desk and can sit down in a classroom where she can learn.
MODERATOR: All right. So having heard the two of you, the voters have just heard the two of you, what is the difference? What is the choice between the two of you on education?
BUSH: The first is, the difference is there is no new accountability measures in Vice President Gores plan. He says hes for voluntary testing. You cant have voluntary testing. You must have mandatory testing. You must say that if you receive money you must show us whether or not children are learning to read and write and add and subtract. Thats the difference. You may claim youve got mandatory testing but you dont, Mr. Vice President. Thats a huge difference. Testing is the cornerstone of reform. You know how I know? Because its the cornerstone of reform in the State of Texas. Republicans and Democrats came together and said what can we do to make our public education the best in the country? Weve done a long way working together to do so. The cornerstone is to have strong accountability in return for money and in return for flexibility. Were going to ask you to show us whether or not — we ask you to post the results on the Internet. We encourage parents to take a look at the comparative results of schools. We have a strong charter school movement that I signed the legislation to get started in the State of Texas. I believe if we find poor children trapped in schools that wont teach, we need to free the parents. We need to expand education savings accounts. Something that the vice president’s running mate supports. Theres big differences. He wont support freeing local districts from the strings of federal money.
GORE: First of all, I do have mandatory testing. I think the governor may not have heard what I said clearly. The voluntary national testing is in addition to the mandatory testing that we require of states. All schools, all school districts, students themselves, and required teacher testing, which goes a step farther than Governor Bush has been willing to go. Here are a couple of differences, though, Jim. Governor Bush is in favor of vouchers which take taxpayer money away from public schools and give them to private schools that are not accountable for how the money is used and dont have to take all applicants. Now, private schools play a great role in our society. All of our children have gone to both public schools and private schools. But I dont think private schools should have a right to take taxpayer money away from public schools at a time when Caley Ellis is standing in that classroom. Let me give you another example. I went to a school in Dade County, Florida where the facilities are so overcrowded the children have to eat lunch in shifts with the first shift for lunch starting at 9:30 in the morning. Look, this is a funding crisis all around the country. There are fewer parents of school-age children as a percentage of the voting population and there is the largest generation of students ever. Were in an information age when learning is more important than ever. 90% of our kids go to public schools. We have to make it the number one priority. Modernize our schools, reduce class size, recruit new teachers, give every child a chance to learn with one-on-one time in a quality — high-quality, safe school. If its a failing school, shut it down and reopen it under a new principal with a turnaround team of specialists the way Governor Jim Hunt does in North Carolina. Here is another difference. The governor, if its a failing school, would leave the children in that failing school for three years and then give a little bit of money to the parents, a down payment on a down payment for private school tuition, and pretend that that would be enough for them to go out and go to a private school. Its an illusion.
MODERATOR: Wait a minute, Governor.
BUSH: Okay. First of all, most of good governance is at the state level. See, here is the mentality. Im going to make the state do this and make the state do that. All Im saying is if you spend money, show us results and test every year, which you do not do, Mr. Vice President. You dont test every year. You can say you do to the cameras but you dont, unless youve changed your plan here on the stage.
GORE: I didnt say that.
BUSH: You need to test every year. Thats how you determine if children are progressing to excellence. Secondly, one of the things that we have to be careful about in politics is throwing money at a system that has not yet been reformed. More money is needed and I spend more money, but step one is to make sure we reform the system to have the system in place that leaves no child behind. Stop this business about asking gosh, how old are you? If youre 10 well put you here, 12 you put here. Start asking the question, what do you know? If you dont know what youre supposed to know, well make sure you do early before its too late.
MODERATOR: New question. Weve been talking about a lot of specific issues. Its often said that in the final analysis about 90% of being the President of the United States is dealing with the unexpected, not with issues that came up in the campaign. Vice President Gore, can you point to a decision, an action you have taken, that illustrates your ability to handle the unexpected, the crisis under fire?
GORE: When the action in Kosovo was dragging on and we were searching for a solution to the problem, our country had defeated the adversary on the battlefield without a single American life being lost in combat. But the dictator Milosevic was hanging on. I invited the former prime minister of Russia to my house and took a risk in asking him to get personally involved, along with the head of Finland, to go to Belgrade and to take a set of proposals from the United States that would constitute basically a surrender by Serbia. But it was a calculated risk that paid off. Now, I could probably give you some other examples of decisions over the last 24 years. I have been in public service for 24 years, Jim. And throughout all that time the people I have fought for have been the middle-class families, and I have been willing to stand up to powerful interests like the big insurance companies, the drug companies, the HMOs, the oil companies. They have good people and they play constructive roles sometimes, but sometimes they get too much power. I cast my lot with the people even when it means that you have to stand up to some powerful interests who are trying to turn the — the policies and the laws to their advantage. You can see it in this campaign. The big drug companies support Governor Bushs prescription drug proposal. They oppose mine because they dont want to get Medicare involved because theyre afraid that Medicare will negotiate lower prices for seniors who currently pay the highest prices of all.
MODERATOR: Governor Bush?
BUSH: Ive been standing up to big Hollywood, big trial lawyers. Was – what was the question? It was about emergencies, wasnt it?
MODERATOR: It was about — okay.
BUSH: You know, as governor, one of the things you have to deal with is catastrophe. I can remember the fires that swept Parker County, Texas. I remember the floods that swept our state. I remember going down to Del Rio, Texas. I have to pay the administration a compliment. James Lee Witt of FEMA has done a really good job of working with governors during times of crisis. But thats the time when youre tested not only — its the time to test your mettle, a time to test your heart when you see people whose lives have been turned upside down. It broke my heart to go to the flood scene in Del Rio where a fellow and his family got completely uprooted. The only thing I knew to do was to get aid as quickly as possible with state and federal help, and to put my arms around the man and his family and cry with them. Thats what governors do. They are often on the front line of catastrophic situations.
MODERATOR: New question. There can be all kinds of crises, Governor. A questions for you. There could be a crisis, for instance, in the financial area, the stock market could take a tumble, there could be a failure of a major financial institution. What is your general attitude toward government intervention in such events?
BUSH: Well, it depends, obviously. But what I would do first and foremost, is I would get in touch with the Federal Reserve Chairman, Alan Greenspan, to find out all the facts and all the circumstances. I would have my Secretary of the Treasury be in touch with the financial centers not only here, but at home. I would make sure that key members of Congress were called in to discuss the gravity of the situation. And I would come up with a game plan to deal with it. Thats what governors end up doing. We end up being problem solvers. We come up with practical, common sense solutions for problems that were confronted with. In this case, in the case of a financial crisis, I would gather all the facts before I made the decision as to what the government ought or ought not to do.
MODERATOR: Vice President Gore?
GORE: First I want to compliment the governor on his response to those fires and floods in Texas. I accompanied James Lee Witt down to Texas when those fires broke out. And FEMA has been a major flagship project of our reinventing government efforts. And I agree, it works extremely well now. On the international financial crises that come up, my friend, Bob Rubin, the former Secretary of Treasury is here, hes a close advisor to me and great friend in all respects. I have had a chance to work with him and Alan Greenspan and others on the crisis following the collapse of the Mexican peso. When the Asian financial crisis raised the risk of world-wide recession that could affect our economy, And now, of course, the euros value has been dropping, but seems to be under control. But it started for me in the last eight years when I had the honor of casting the tie-breaking vote to end the old economic plan here at home and put into place a new economic plan that has helped us to make some progress, 22 million new jobs, the greatest prosperity ever. But its not good enough. My attitude is you aint seen nothing yet. We need to do more and better.
MODERATOR: So, Governor, would you agree there is no basic difference here on intervening — on federal government intervening in what might be seen by others to be a private financial crisis?
BUSH: No, theres no difference on that. There is a difference, though, as to what the economy has meant. I think the economy has meant more for the Gore and Clinton folks than the Gore and Clinton folks have meant for the economy. I think most of the economic growth that has taken place is a result of ingenuity and hard work and entrepreneurship and thats the role of goverment to encourage that. In terms of in response to the question, no.
GORE: Can I comment on that?
MODERATOR: You may.
GORE: You know, I think the American people deserve credit for the great economy that we have. Its their ingenuity, I agree with that. But you know, they were working pretty hard eight years ago. And now they had ingenuity eight years ago. The difference is weve got a new policy. And instead of concentrating on tax cuts mostly for the wealthy, we want — I want tax cuts for the middle-class families and I want to continue the prosperity and make sure that it enriches not just a few but all of our families. We have gone from the biggest deficits to the biggest surpluses. We have gone from a triple-dip recession during the previous 12 years to a tripling of the stock market. Instead of a high unemployment, we have the lowest African-American and Latin American unemployment rates in history and 22 million new jobs. Its not good enough. Too many people have been left behind. We have got to do much more. The key is job training, education, investments in health care and education, environment, retirement security. And incidentally, we have got to preserve Social Security. Im totally opposed to diverting one out of every six dollars out of the Social Security trust fund, as the Governor has proposed, into the stock market. I want new incentives for savings and investment for the young couples who are working hard so they can save and invest on their own on top of Social Security, not at the expense of Social Security, as the governor proposes.
BUSH: Two points. One, a lot of folks are still waiting for that 1992 middle-class tax cut. I remember the vice president saying, “Just give us a chance to get up there, were going to make sure you get tax cuts.” It didnt happen. Now hes having to say that again. Theyve had their chance to deliver a tax cut to you. Secondly, the surest way to bust this economy is to increase the role and size of the federal budget. The Senate Budget Committee did a study of the vice presidents expenditures. Its been projected that they could conceivably bust the budget by $900 billion. That means hell either have to raise your taxes by $900 billion or go into the Social Security surplus for $900 billion. This is a plan that is going to increase the bureaucracy by 20,000 people. His targeted tax cut is so detailed, so much fine print that it is going to require numerous IRS agents. We need somebody to simplify the code, to be fair, to continue prosperity by sharing some of the surplus with the people who pay the bills, particularly those at the bottom end of the economic ladder.
GORE: If I could respond, Jim. What hes quoting is not the Senate Budget Commiitte, it is a partisan press release by the Republicans on the Senate Budget Committee thats not worth the government — the taxpayer-paid paper that its printed on. Now, as for 20,000 new bureaucrats, as you call them, you know, the size of the federal government will go down in a Gore administration. In the reinventing government program you just look at the numbers. It is 300,000 people smaller today than it was eight years ago. Now, the fact is youre going to have a hard time convincing folks that we were a whole lot better off eight years ago than we are today. But thats not the question. The question is, will we be better off four years from now than we are today? And as for the surest way to threaten our prosperity, having a $1.9 trillion tax cut, almost half of which goes to the wealthy, and a $1 trillion Social Security privatization proposal is the surest way to put our budget into deficit – raise interest rates and put our prosperity at risk.
BUSH: I cant let the man continue with fuzzy math. It is 1.3 trillion Mr. Vice President. It will go to everybody who pays taxes. Im not going to be the kind of president that says you get tax relief and you dont. Im not going to be a picker and chooser. What is fair is everybody who pays taxes ought to get relief.
MODERATOR: I thought we cleared this up a while ago. New question on Social Security. Both of you have Social Security reform plans, so we could spend the rest of the evening and two or three other evenings talking about them in detail. We wont do that. But —
GORE: Suits me.
MODERATOR: Many experts, including Federal Reserve Chairman Greenspan, Vice President Gore, say that it will be impossible for either of you, essentially, to keep the system viable on its own during the coming baby boomer retirement onslaught without either reducing benefits or increasing taxes. You disagree?
GORE: I do disagree. Because if we can keep our prosperity going, if we can continue balancing the budget and paying down the debt, then the strong economy keeps generating surpluses. Here is my plan. I will keep Social Security in a lockbox and that pays down the national debt. And the interest savings I would put right back into Social Security. That extends the life of Social Security for 55 years. Now, I think that its very important to understand that cutting benefits under Social Security means that people like Winifred Skinner from Des Moines, Iowa, who is here, would really have a much harder time. Because there are millions of seniors who are living almost hand to mouth. And you talk about cutting benefits. I dont go along with it. I am opposed to it. Im also opposed to a plan that diverts 1 out of every $6 away from the Social Security Trust Fund. Social Security is a trust fund that pays the checks this year with the money that is paid into Social Security this year. The governor wants to divert 1 out of every $6 off into the stock market, which means that he would drain a trillion dollars out of the Social Security Trust Fund in this generation over the next ten years, and Social Security under that approach would go bankrupt within this generation. His leading advisor on this plan actually said that would be okay, because then the Social Security Trust Fund could start borrowing. It would borrow up to $3 trillion. Now, Social Security has never done that. And I dont think it should do that. I think it should stay in a lockbox, and Ill tell you this. I will veto anything that takes money out of Social Security for privatization or anything else other than Social Security.
BUSH: I thought it was interesting that on the two minutes he spent about a million-and-a-half on my plan, which means he doesnt want you to know what hes doing is loading up IOUs for future generations. He puts no real assets into the Social Security system. The revenues exceed the expenses in Social Security until the year 2015 which means all retirees are going to get the promises made. For those of you who he wants to scare into the voting booth to vote for him, hear me loud and clear. A promise made will be a promise kept. You bet we want to allow younger workers to take some of their own money. Thats the difference of opinion. The vice president thinks its the governments money. The payroll taxes are your money. You ought to put it in prudent, safe investments so that $1 trillion over the next ten years grows to be $3 trillion. The money stays within the Social Security system. Its a part of the Social Security system. He claims it will be out of Social Security. Its your money, its a part of your retirement benefit. Its a fundamental difference between what we believe. I want you to have your own asset that you can call your own. That you can pass on from one generation to the next. I want to get a better rate of return for your own money than the paltry 2% that the current Social Security Trust gets today. Mr. Greenspan I thought missed an opportunity to say theres a third way, and that is to get a better rate of return on the Social Security monies coming into the trust. There is $2.3 trillion of surplus that we can use to make sure that younger workers have a Social Security plan in the future. If were smart and if we trust workers and if we understand the power of the compounding rate of interest.
GORE: Here is the difference. I give a new incentive for younger workers to save their own money and invest their own money, but not at the expense of Social Security, on top of Social Security. My plan is Social Security plus. The governors plan is Social Security minus. Your future benefits would be cut by the amount thats diverted into the stock market. If you make bad investments, thats too bad. But even before then the problem hits because the money contributed to Social Security this year is an entitlement. Thats how it works. And the money is used to pay the benefits for seniors this year. If you cut the amount going in 1 out of every $6, then you have to cut the value of each check by 1 out of every $6 unless you come up with the money from somewhere else. I would like to know from the governor — I know were not supposed to ask each other questions — but Id be interested in knowing, does that trillion dollars come from the trust fund, or does it come from the rest of the budget?
BUSH: No. Theres enough money to pay seniors today in the current affairs of Social Security. The trillion comes from the surplus. Surplus is money — more money than needed. Let me tell you what your plan is. Its not Social Security plus, its Social Security plus huge debt. That is what it is. You leave future generations with tremendous IOUs. Its time to have a leader that doesnt put off tomorrow what we should do today. Its time to have somebody to step up and say look, lets let younger workers take some of their own money and under certain guidelines invest it in the private markets. The safest of federal investments yields 4%. Thats twice the amount of rate of return than the current Social Security Trust. Its a fundamental difference of opinion here, folks. Younger worker after younger worker hears my call that says I trust you. And you know what, the issue is changing. Seniors now understand that the promise made will be a promise kept, but younger workers now understand we better have a government that trusts them and thats exactly what Im going to do.
GORE: Could I respond to that, Jim? This is a big issue. Could we do another round on it?
MODERATOR: Were almost out of time.
GORE: Just briefly. When FDR established Social Security, they didnt call them IOUs, they called it the full faith and credit of the United States. If you dont have trust in that, I do. If you take it out of the surplus in the trust fund, that means the trust fund goes bankrupt in this generation within 20 years.
BUSH: This is a government that thinks a 2% rate of return on your money is satisfactory. Its not. This is a government that says younger workers cant possibly have their own assets. We need to think differently about the issue. We need to make sure our seniors get the promise made. If we dont trust younger workers to manage some of their own money with the Social Security surplus, to grow from $1 trillion to $3 trillion, it will be impossible to bridge the gap without it. What Mr. Gores plan will do causing huge payroll taxes or major benefit reductions.
MODERATOR: New question. Are there issues of character that distinguish you from Vice President Gore?
BUSH: The man loves his wife and I appreciate that a lot. And I love mine. The man loves his family a lot, and I appreciate that, because I love my family. I think the thing that discouraged me about the vice president was uttering those famous words, “No controlling legal authority.” I felt like there needed to be a better sense of responsibility of what was going on in the White House. I believe that — I believe theyve moved that sign, “The buck stops here” from the Oval Office desk to “The buck stops here” on the Lincoln bedroom. Its not good for the country and its not right. We need to have a new look about how we conduct ourselves in office. Theres a huge trust. I see it all the time when people come up to me and say, I dont want you to let me down again. And we can do better than the past administration has done. Its time for a fresh start. Its time for a new look. Its time for a fresh start after a season of cynicism. And so I dont know the man well, but Ive been disappointed about how he and his administration have conducted the fundraising affairs. You know, going to a Buddhist temple and then claiming it wasnt a fundraiser isnt my view of responsibility.
MODERATOR: Vice President Gore?
GORE: I think we ought to attack our countrys problems, not attack each other. I want to spend my time making this country even better than it is, not trying to make you out to be a bad person. You may want to focus on scandal. I want to focus on results. As I said a couple of months ago, I stand here as my own man and I want you to see me for who I really am. Tipper and I have been married for 30 years. We became grandparents a year-and-a-half ago. Weve got four children. I have devoted 24 years of my life to public service and Ive said this before and Ill say it again, if you entrust me with the presidency, I may not be the most exciting politician, but I will work hard for you every day. I will fight for middle-class families and working men and women and I will never let you down.
MODERATOR: So, Governor, what are you saying when you mention the fundraising scandals or the fundraising charges that involve Vice President Gore? What are you saying that the voters should take from that thats relevant to this election?
BUSH: They ought to factor in it when they go to the voting booth.
MODERATOR: In what way?
BUSH: I think people need to be held responsible for the actions they take in life. I think that — well, I think thats part of the need for a cultural change. We need to say we each need to be responsible for what we do. People in the highest office of the land must be responsible for decisions they make in life. And thats the way Ive conducted myself as Governor of Texas and thats the way Ill conduct myself as President of the United States, should I be fortunate enough to earn your vote.
MODERATOR: Are you saying all this is irrelevant, Vice President Gore?
GORE: No. I think the American people should take into account who we are as individuals, what our experience is, what our positions are on the issues and proposals are. Im asking you to see me for who I really am. Im offering you my own vision, my own experience, my own proposals. And incidentally, one of them is this. This current campaign financing system has not reflected credit on anybody in either party. And thats one of the reasons Ive said before, and Ill pledge here tonight, if Im president, the very first bill that Joe Lieberman and I will send to the United States Congress is the McCain-Feingold campaign finance reform bill. And the reason its that important is that all of the other issues, whether prescription drugs for all seniors that are opposed by the drug companies or the patients bill of rights to take the decisions away from the HMOs and give them to the doctors and nurses, opposed by the HMOs and insurance companies, all these other proposals are going to be a lot easier to get passed for the American people if we limit the influence of special interest money and give democracy back to the American people. And I wish Governor Bush would join me this evening in endorsing the McCain-Feingold Campaign Finance Reform Bill.
BUSH: You know, this man has no credibility on the issue. As a matter of fact, I read in the “New York Times” where he said he co-sponsored the McCain-Feingold Campaign Fundraising Bill. But he wasnt in the Senate with Senator Feingold. And so, look, Im going to — what you need to know about me is I will uphold the law, Im going to have an attorney general that enforces the law. The time for campaign funding reform is after the election. This man has outspent me and the special interests are outspending me. And I am not going to lay down my arms in the middle of the campaign for somebody who has got no credibility on the issue.
MODERATOR: Senator McCain — hold on one second. Senator McCain said in August, “It doesnt matter which one of you is President of the United States in January, there is going to be blood on the floor of the United States Senate,” and hell tie up the Senate until campaign finance reform is passed that includes a ban on soft money. First of all, would you support that effort by him, or would you sign a bill that is finally passed that included —
BUSH: I would support an effort to ban corporate soft money and labor union soft money so long as there was dues check-off. Ive campaigned on this since the primaries. I believe there needs to be instant disclosure on the Internet as to who has given to who. I think we need to fully enforce the law. I think we need to have an attorney general that says if a law is broken, well enforce it. Be strict and firm about it.
GORE: Look, Governor Bush, you have attacked my character and credibility and I am not going to respond in kind. I think we ought to focus on the problems and not attack each other. One of the serious problems, hear me well, is that our system of government is being undermined by too much influence coming from special interest money. We have to get a handle on it. And like John McCain, I have learned from experience, and its not a new position for me. 24 years ago I supported full public financing of all federal elections. And anybody who thinks Im just saying it, it will be the first bill I send to the Congress. I want you to know I care passionately about this and I will fight until it becomes law.
BUSH: I want people to hear what he just said. He is for full public financing of Congressional elections. Im absolutely, adamently opposed to that. I dont want the government financing congressional elections.
MODERATOR: On that wonderful note of disagreement, we have to stop here and we want to go now to your closing statements. Governor Bush is first. You have two minutes.
BUSH: Thank you, Jim. Thank the University of Massachusetts and Mr. Vice President, thank you. It has been a good, lively exchange. There is a huge difference of opinion. Mine is I want to empower people in their own lives. I also want to go to Washington to get some positive things done. It is going to require a new spirit. A spirit of cooperation. It will require the ability of a Republican president to reach out across the partisan divide and to say to Democrats, lets come together to do what is right for America. Its been my record as Governor of Texas, it will be how I conduct myself if Im fortunate enough to earn your vote as President of the United States. I want to finally get something done on Medicare. I want to make sure prescription drugs are available for all seniors. And I want seniors to have additional choices when it comes to choosing their health care plans. I want to finally get something done on Social Security. I want to make sure the seniors have the promise made will be a promise kept, but I want younger workers to be able to manage some of their own money, some of their own payroll taxes in the private sector under certain guidelines to get a better rate of return on your own money. I want to rebuild our military to keep the peace. I want to have a strong hand when it comes to the United States in world affairs. I dont want to try to put our troops in all places at all times. I dont want to be the worlds policeman, I want to be the worlds peacemaker by having a military of high morale and a military that is well-equipped. I want anti-ballistic missile systems to protect ourselves and our allies from a rogue nation that may try to hold us hostage or blackmail our allies and friends. I want to make sure the education system fulfills its hope and promise. Ive had a strong record of working with Democrats and Republicans in Texas to make sure no child is left behind. I understand the limited role of the federal government, but it could be a constructive role when it comes to reform, by insisting that there be a strong accountability systems. My intentions are to earn your vote and earn your confidence. Im asking for your vote. I want you to be on my team. And for those of you working, thanks from the bottom of my heart. For those of you making up your mind, I would be honored to have your support.
MODERATOR: Vice President Gore, two minutes.
GORE: I want to thank everybody who watched and listened tonight because this is indeed a crucial time in American history. Were at a fork in the road. We have this incredible prosperity, but a lot of people have been left behind. And we have a very important decision to make. Will we use the prosperity to enrich all of our families and not just a few? One important way of looking at this is to ask who are you going to fight for? Throughout my career in public service, I have fought for the working men and women of this country, middle-class families. Why? Because you are the ones who have the hardest time paying taxes, the hardest time making ends meet. You are the ones who are making car payments and mortgage payments and doing right by your kids. And a lot of times there are powerful forces that are against you. Make no mistake about it, they do have undue influence in Washington, D.C. and it makes a difference if you have a president who will fight for you. I know one thing about the position of president, its the only position in our Constitution that is filled by an individual who is given the responsibility to fight not just for one state or one district or the well-connected or wealthy, but to fight for all of the people, including especially those who most need somebody who will stand up and take on whatever powerful forces might stand in the way. There is a woman named Winifred Skinner here tonight from Iowa. I mentioned her earlier. Shes 79 years old. She has Social Security. Im not going to cut her benefits or support any proposal that would. She gets a small pension, but in order to pay for her prescription drug benefits, she has to go out seven days a week several hours a day picking up cans. She came all the way from Iowa in a Winnebago with her poodle in order attend here tonight. I want to tell her, Ill fight for a prescription drug benefit for all seniors and fight for the people of this country for a prosperity that benefits all.
MODERATOR: We will continue this dialogue next week on October 11th at Wake Forest University in Winston-Salem, North Carolina. The format then will be more informal, more conversational with the two candidates seated at a table with me. The third will be October 17th at Washington University in St. Louis, and that will follow a town-hall type format. Also on the day after tomorrow, October 5, there is a 90-minute debate between the democratic nominee for vice president, Senator Joe Lieberman and the republican candidate for vice president former Secretary of Defense Dick Cheney. It will be held at Centre College in Danville, Kentucky. The moderator will be Bernard Shaw of CNN. Thank you, Governor Bush, Vice President Gore. See you next week. For now from Boston, Im Jim Lehrer. Thank you, and good night.
(APPLAUSE)

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,49 @@
import os
import re
import unicodedata
def sanitize_string(text):
# Normalize Unicode characters
text = unicodedata.normalize('NFKD', text)
# Replace specific problematic characters
text = text.replace('’', "'")
text = text.replace('“', '"')
text = text.replace('â€', '"')
# Remove any remaining non-ASCII characters
text = text.encode('ascii', 'ignore').decode('ascii')
return text.strip()
def parse_debate(file_path):
with open(file_path, encoding='utf-8') as file:
content = file.read()
# Split the content into episodes
episodes = re.split(r'\n(?=(?:[A-Z]+):)', content)
parsed_episodes = []
for episode in episodes:
# Extract the role and statement
match = re.match(r'([A-Z]+):\s*(.*)', episode.strip(), re.DOTALL)
if match:
role, statement = match.groups()
parsed_episodes.append(
{'role': sanitize_string(role), 'statement': sanitize_string(statement)}
)
return parsed_episodes
def get_debate_messages():
file_path = 'bush_gore_debate.txt'
script_dir = os.path.dirname(__file__)
relative_path = os.path.join(script_dir, file_path)
return parse_debate(relative_path)
def get_kennedy_debate_messages():
file_path = 'kennedy_nixon_debate.txt'
script_dir = os.path.dirname(__file__)
relative_path = os.path.join(script_dir, file_path)
return parse_debate(relative_path)

View File

@@ -0,0 +1,99 @@
"""
Copyright 2024, Zep Software, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import asyncio
import logging
import os
import sys
from datetime import datetime, timedelta
from dotenv import load_dotenv
from examples.presidential_debates.parser import get_debate_messages
from graphiti_core import Graphiti
from graphiti_core.llm_client.anthropic_client import AnthropicClient
from graphiti_core.llm_client.config import LLMConfig
from graphiti_core.utils.maintenance.graph_data_operations import clear_data
load_dotenv()
neo4j_uri = os.environ.get('NEO4J_URI') or 'bolt://localhost:7687'
neo4j_user = os.environ.get('NEO4J_USER') or 'neo4j'
neo4j_password = os.environ.get('NEO4J_PASSWORD') or 'password'
def setup_logging():
# Create a logger
logger = logging.getLogger()
logger.setLevel(logging.INFO) # Set the logging level to INFO
# Create console handler and set level to INFO
console_handler = logging.StreamHandler(sys.stdout)
console_handler.setLevel(logging.INFO)
# Create formatter
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# Add formatter to console handler
console_handler.setFormatter(formatter)
# Add console handler to logger
logger.addHandler(console_handler)
return logger
async def main():
setup_logging()
llm_client = AnthropicClient(LLMConfig(api_key=os.environ.get('ANTHROPIC_API_KEY')))
client = Graphiti(neo4j_uri, neo4j_user, neo4j_password, llm_client)
messages = get_debate_messages()
print(messages[:3])
print(len(messages))
# i need to create tuples from each 3 messages in the messages
message_tuples = [messages[i : i + 5] for i in range(0, len(messages), 5)]
# # neets to be october 3 2000
now = datetime(2000, 10, 3)
# episodes: list[BulkEpisode] = [
# BulkEpisode(
# name=f'Statement {i + 1}',
# content=f"{episode['role']}: {episode['statement']}",
# source_description='Bush Gore presidential_debates 2001',
# episode_type='string',
# reference_time=now + timedelta(seconds=i * 10),
# )
# for i, episode in enumerate(messages)
# ]
# await clear_data(client.driver)
# await client.build_indices_and_constraints()
# await client.add_episode_bulk(episodes)
await clear_data(client.driver)
await client.build_indices_and_constraints()
for i, episode_list in enumerate(message_tuples[:4]):
combined_roles_and_statements_str = ''.join(
f"{episode['role']}: {episode['statement']}\n" for episode in episode_list
)
await client.add_episode(
name=f'Statement {i + 1}',
episode_body=combined_roles_and_statements_str,
source_description='Bush Gore depate 2001',
reference_time=now + timedelta(seconds=i * 10),
)
asyncio.run(main())

View File

@@ -0,0 +1,77 @@
"""
Copyright 2024, Zep Software, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import os
import re
def parse_script(filename):
current_speaker = None
current_speech = []
messages = []
with open(filename) as file:
for line in file:
line = line.strip()
# Check if this line is a new speaker
if (
line
and line.isupper()
and not line.startswith('ACT')
and not line.startswith('SCENE')
):
# If we have a current speaker, save their message
if current_speaker:
messages.append((current_speaker, ' '.join(current_speech)))
# Start a new speech
current_speaker = line
current_speech = []
elif line and not line.startswith('[') and current_speaker:
# Add this line to the current speech
current_speech.append(line)
# Add the last speech
if current_speaker:
messages.append((current_speaker, ' '.join(current_speech)))
return messages
def escape_special_characters(text):
# Define the special characters to remove
special_chars = r'+-&|!(){}[]^"~*?:\/'
# Use regex to replace all special characters with an empty string
return re.sub(f'[{re.escape(special_chars)}]', '', text)
# Test the function with a sample line from your text
sample_text = "GREGORY: To move is to stir; and to be valiant is to stand\\: therefore, if thou art moved, thou runn'st away."
escaped_text = escape_special_characters(sample_text)
print(escaped_text)
def get_romeo_messages():
file_path = 'romeo_act2.txt'
script_dir = os.path.dirname(__file__)
relative_path = os.path.join(script_dir, file_path)
# Use the function with escaping
return [
(speaker, escape_special_characters(speech))
for speaker, speech in parse_script(relative_path)
]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,937 @@
ROMEO
Can I go forward when my heart is here?
Turn back, dull earth, and find thy centre out.
He climbs the wall, and leaps down within it
Enter BENVOLIO and MERCUTIO
BENVOLIO
Romeo! my cousin Romeo!
MERCUTIO
He is wise;
And, on my lie, hath stol'n him home to bed.
BENVOLIO
He ran this way, and leap'd this orchard wall:
Call, good Mercutio.
MERCUTIO
Nay, I'll conjure too.
Romeo! humours! madman! passion! lover!
Appear thou in the likeness of a sigh:
Speak but one rhyme, and I am satisfied;
Cry but 'Ay me!' pronounce but 'love' and 'dove;'
Speak to my gossip Venus one fair word,
One nick-name for her purblind son and heir,
Young Adam Cupid, he that shot so trim,
When King Cophetua loved the beggar-maid!
He heareth not, he stirreth not, he moveth not;
The ape is dead, and I must conjure him.
I conjure thee by Rosaline's bright eyes,
By her high forehead and her scarlet lip,
By her fine foot, straight leg and quivering thigh
And the demesnes that there adjacent lie,
That in thy likeness thou appear to us!
BENVOLIO
And if he hear thee, thou wilt anger him.
MERCUTIO
This cannot anger him: 'twould anger him
To raise a spirit in his mistress' circle
Of some strange nature, letting it there stand
Till she had laid it and conjured it down;
That were some spite: my invocation
Is fair and honest, and in his mistres s' name
I conjure only but to raise up him.
BENVOLIO
Come, he hath hid himself among these trees,
To be consorted with the humorous night:
Blind is his love and best befits the dark.
MERCUTIO
If love be blind, love cannot hit the mark.
Now will he sit under a medlar tree,
And wish his mistress were that kind of fruit
As maids call medlars, when they laugh alone.
Romeo, that she were, O, that she were
An open et caetera, thou a poperin pear!
Romeo, good night: I'll to my truckle-bed;
This field-bed is too cold for me to sleep:
Come, shall we go?
BENVOLIO
Go, then; for 'tis in vain
To seek him here that means not to be found.
Exeunt
SCENE II. Capulet's orchard.
Enter ROMEO
ROMEO
He jests at scars that never felt a wound.
JULIET appears above at a window
But, soft! what light through yonder window breaks?
It is the east, and Juliet is the sun.
Arise, fair sun, and kill the envious moon,
Who is already sick and pale with grief,
That thou her maid art far more fair than she:
Be not her maid, since she is envious;
Her vestal livery is but sick and green
And none but fools do wear it; cast it off.
It is my lady, O, it is my love!
O, that she knew she were!
She speaks yet she says nothing: what of that?
Her eye discourses; I will answer it.
I am too bold, 'tis not to me she speaks:
Two of the fairest stars in all the heaven,
Having some business, do entreat her eyes
To twinkle in their spheres till they return.
What if her eyes were there, they in her head?
The brightness of her cheek would shame those stars,
As daylight doth a lamp; her eyes in heaven
Would through the airy region stream so bright
That birds would sing and think it were not night.
See, how she leans her cheek upon her hand!
O, that I were a glove upon that hand,
That I might touch that cheek!
JULIET
Ay me!
ROMEO
She speaks:
O, speak again, bright angel! for thou art
As glorious to this night, being o'er my head
As is a winged messenger of heaven
Unto the white-upturned wondering eyes
Of mortals that fall back to gaze on him
When he bestrides the lazy-pacing clouds
And sails upon the bosom of the air.
JULIET
O Romeo, Romeo! wherefore art thou Romeo?
Deny thy father and refuse thy name;
Or, if thou wilt not, be but sworn my love,
And I'll no longer be a Capulet.
ROMEO
[Aside] Shall I hear more, or shall I speak at this?
JULIET
'Tis but thy name that is my enemy;
Thou art thyself, though not a Montague.
What's Montague? it is nor hand, nor foot,
Nor arm, nor face, nor any other part
Belonging to a man. O, be some other name!
What's in a name? that which we call a rose
By any other name would smell as sweet;
So Romeo would, were he not Romeo call'd,
Retain that dear perfection which he owes
Without that title. Romeo, doff thy name,
And for that name which is no part of thee
Take all myself.
ROMEO
I take thee at thy word:
Call me but love, and I'll be new baptized;
Henceforth I never will be Romeo.
JULIET
What man art thou that thus bescreen'd in night
So stumblest on my counsel?
ROMEO
By a name
I know not how to tell thee who I am:
My name, dear saint, is hateful to myself,
Because it is an enemy to thee;
Had I it written, I would tear the word.
JULIET
My ears have not yet drunk a hundred words
Of that tongue's utterance, yet I know the sound:
Art thou not Romeo and a Montague?
ROMEO
Neither, fair saint, if either thee dislike.
JULIET
How camest thou hither, tell me, and wherefore?
The orchard walls are high and hard to climb,
And the place death, considering who thou art,
If any of my kinsmen find thee here.
ROMEO
With love's light wings did I o'er-perch these walls;
For stony limits cannot hold love out,
And what love can do that dares love attempt;
Therefore thy kinsmen are no let to me.
JULIET
If they do see thee, they will murder thee.
ROMEO
Alack, there lies more peril in thine eye
Than twenty of their swords: look thou but sweet,
And I am proof against their enmity.
JULIET
I would not for the world they saw thee here.
ROMEO
I have night's cloak to hide me from their sight;
And but thou love me, let them find me here:
My life were better ended by their hate,
Than death prorogued, wanting of thy love.
JULIET
By whose direction found'st thou out this place?
ROMEO
By love, who first did prompt me to inquire;
He lent me counsel and I lent him eyes.
I am no pilot; yet, wert thou as far
As that vast shore wash'd with the farthest sea,
I would adventure for such merchandise.
JULIET
Thou know'st the mask of night is on my face,
Else would a maiden blush bepaint my cheek
For that which thou hast heard me speak to-night
Fain would I dwell on form, fain, fain deny
What I have spoke: but farewell compliment!
Dost thou love me? I know thou wilt say 'Ay,'
And I will take thy word: yet if thou swear'st,
Thou mayst prove false; at lovers' perjuries
Then say, Jove laughs. O gentle Romeo,
If thou dost love, pronounce it faithfully:
Or if thou think'st I am too quickly won,
I'll frown and be perverse an say thee nay,
So thou wilt woo; but else, not for the world.
In truth, fair Montague, I am too fond,
And therefore thou mayst think my 'havior light:
But trust me, gentleman, I'll prove more true
Than those that have more cunning to be strange.
I should have been more strange, I must confess,
But that thou overheard'st, ere I was ware,
My true love's passion: therefore pardon me,
And not impute this yielding to light love,
Which the dark night hath so discovered.
ROMEO
Lady, by yonder blessed moon I swear
That tips with silver all these fruit-tree tops--
JULIET
O, swear not by the moon, the inconstant moon,
That monthly changes in her circled orb,
Lest that thy love prove likewise variable.
ROMEO
What shall I swear by?
JULIET
Do not swear at all;
Or, if thou wilt, swear by thy gracious self,
Which is the god of my idolatry,
And I'll believe thee.
ROMEO
If my heart's dear love--
JULIET
Well, do not swear: although I joy in thee,
I have no joy of this contract to-night:
It is too rash, too unadvised, too sudden;
Too like the lightning, which doth cease to be
Ere one can say 'It lightens.' Sweet, good night!
This bud of love, by summer's ripening breath,
May prove a beauteous flower when next we meet.
Good night, good night! as sweet repose and rest
Come to thy heart as that within my breast!
ROMEO
O, wilt thou leave me so unsatisfied?
JULIET
What satisfaction canst thou have to-night?
ROMEO
The exchange of thy love's faithful vow for mine.
JULIET
I gave thee mine before thou didst request it:
And yet I would it were to give again.
ROMEO
Wouldst thou withdraw it? for what purpose, love?
JULIET
But to be frank, and give it thee again.
And yet I wish but for the thing I have:
My bounty is as boundless as the sea,
My love as deep; the more I give to thee,
The more I have, for both are infinite.
Nurse calls within
I hear some noise within; dear love, adieu!
Anon, good nurse! Sweet Montague, be true.
Stay but a little, I will come again.
Exit, above
ROMEO
O blessed, blessed night! I am afeard.
Being in night, all this is but a dream,
Too flattering-sweet to be substantial.
Re-enter JULIET, above
JULIET
Three words, dear Romeo, and good night indeed.
If that thy bent of love be honourable,
Thy purpose marriage, send me word to-morrow,
By one that I'll procure to come to thee,
Where and what time thou wilt perform the rite;
And all my fortunes at thy foot I'll lay
And follow thee my lord throughout the world.
Nurse
[Within] Madam!
JULIET
I come, anon.--But if thou mean'st not well,
I do beseech thee--
Nurse
[Within] Madam!
JULIET
By and by, I come:--
To cease thy suit, and leave me to my grief:
To-morrow will I send.
ROMEO
So thrive my soul--
JULIET
A thousand times good night!
Exit, above
ROMEO
A thousand times the worse, to want thy light.
Love goes toward love, as schoolboys from
their books,
But love from love, toward school with heavy looks.
Retiring
Re-enter JULIET, above
JULIET
Hist! Romeo, hist! O, for a falconer's voice,
To lure this tassel-gentle back again!
Bondage is hoarse, and may not speak aloud;
Else would I tear the cave where Echo lies,
And make her airy tongue more hoarse than mine,
With repetition of my Romeo's name.
ROMEO
It is my soul that calls upon my name:
How silver-sweet sound lovers' tongues by night,
Like softest music to attending ears!
JULIET
Romeo!
ROMEO
My dear?
JULIET
At what o'clock to-morrow
Shall I send to thee?
ROMEO
At the hour of nine.
JULIET
I will not fail: 'tis twenty years till then.
I have forgot why I did call thee back.
ROMEO
Let me stand here till thou remember it.
JULIET
I shall forget, to have thee still stand there,
Remembering how I love thy company.
ROMEO
And I'll still stay, to have thee still forget,
Forgetting any other home but this.
JULIET
'Tis almost morning; I would have thee gone:
And yet no further than a wanton's bird;
Who lets it hop a little from her hand,
Like a poor prisoner in his twisted gyves,
And with a silk thread plucks it back again,
So loving-jealous of his liberty.
ROMEO
I would I were thy bird.
JULIET
Sweet, so would I:
Yet I should kill thee with much cherishing.
Good night, good night! parting is such
sweet sorrow,
That I shall say good night till it be morrow.
Exit above
ROMEO
Sleep dwell upon thine eyes, peace in thy breast!
Would I were sleep and peace, so sweet to rest!
Hence will I to my ghostly father's cell,
His help to crave, and my dear hap to tell.
Exit
SCENE III. Friar Laurence's cell.
Enter FRIAR LAURENCE, with a basket
FRIAR LAURENCE
The grey-eyed morn smiles on the frowning night,
Chequering the eastern clouds with streaks of light,
And flecked darkness like a drunkard reels
From forth day's path and Titan's fiery wheels:
Now, ere the sun advance his burning eye,
The day to cheer and night's dank dew to dry,
I must up-fill this osier cage of ours
With baleful weeds and precious-juiced flowers.
The earth that's nature's mother is her tomb;
What is her burying grave that is her womb,
And from her womb children of divers kind
We sucking on her natural bosom find,
Many for many virtues excellent,
None but for some and yet all different.
O, mickle is the powerful grace that lies
In herbs, plants, stones, and their true qualities:
For nought so vile that on the earth doth live
But to the earth some special good doth give,
Nor aught so good but strain'd from that fair use
Revolts from true birth, stumbling on abuse:
Virtue itself turns vice, being misapplied;
And vice sometimes by action dignified.
Within the infant rind of this small flower
Poison hath residence and medicine power:
For this, being smelt, with that part cheers each part;
Being tasted, slays all senses with the heart.
Two such opposed kings encamp them still
In man as well as herbs, grace and rude will;
And where the worser is predominant,
Full soon the canker death eats up that plant.
Enter ROMEO
ROMEO
Good morrow, father.
FRIAR LAURENCE
Benedicite!
What early tongue so sweet saluteth me?
Young son, it argues a distemper'd head
So soon to bid good morrow to thy bed:
Care keeps his watch in every old man's eye,
And where care lodges, sleep will never lie;
But where unbruised youth with unstuff'd brain
Doth couch his limbs, there golden sleep doth reign:
Therefore thy earliness doth me assure
Thou art up-roused by some distemperature;
Or if not so, then here I hit it right,
Our Romeo hath not been in bed to-night.
ROMEO
That last is true; the sweeter rest was mine.
FRIAR LAURENCE
God pardon sin! wast thou with Rosaline?
ROMEO
With Rosaline, my ghostly father? no;
I have forgot that name, and that name's woe.
FRIAR LAURENCE
That's my good son: but where hast thou been, then?
ROMEO
I'll tell thee, ere thou ask it me again.
I have been feasting with mine enemy,
Where on a sudden one hath wounded me,
That's by me wounded: both our remedies
Within thy help and holy physic lies:
I bear no hatred, blessed man, for, lo,
My intercession likewise steads my foe.
FRIAR LAURENCE
Be plain, good son, and homely in thy drift;
Riddling confession finds but riddling shrift.
ROMEO
Then plainly know my heart's dear love is set
On the fair daughter of rich Capulet:
As mine on hers, so hers is set on mine;
And all combined, save what thou must combine
By holy marriage: when and where and how
We met, we woo'd and made exchange of vow,
I'll tell thee as we pass; but this I pray,
That thou consent to marry us to-day.
FRIAR LAURENCE
Holy Saint Francis, what a change is here!
Is Rosaline, whom thou didst love so dear,
So soon forsaken? young men's love then lies
Not truly in their hearts, but in their eyes.
Jesu Maria, what a deal of brine
Hath wash'd thy sallow cheeks for Rosaline!
How much salt water thrown away in waste,
To season love, that of it doth not taste!
The sun not yet thy sighs from heaven clears,
Thy old groans ring yet in my ancient ears;
Lo, here upon thy cheek the stain doth sit
Of an old tear that is not wash'd off yet:
If e'er thou wast thyself and these woes thine,
Thou and these woes were all for Rosaline:
And art thou changed? pronounce this sentence then,
Women may fall, when there's no strength in men.
ROMEO
Thou chid'st me oft for loving Rosaline.
FRIAR LAURENCE
For doting, not for loving, pupil mine.
ROMEO
And bad'st me bury love.
FRIAR LAURENCE
Not in a grave,
To lay one in, another out to have.
ROMEO
I pray thee, chide not; she whom I love now
Doth grace for grace and love for love allow;
The other did not so.
FRIAR LAURENCE
O, she knew well
Thy love did read by rote and could not spell.
But come, young waverer, come, go with me,
In one respect I'll thy assistant be;
For this alliance may so happy prove,
To turn your households' rancour to pure love.
ROMEO
O, let us hence; I stand on sudden haste.
FRIAR LAURENCE
Wisely and slow; they stumble that run fast.
Exeunt
SCENE IV. A street.
Enter BENVOLIO and MERCUTIO
MERCUTIO
Where the devil should this Romeo be?
Came he not home to-night?
BENVOLIO
Not to his father's; I spoke with his man.
MERCUTIO
Ah, that same pale hard-hearted wench, that Rosaline.
Torments him so, that he will sure run mad.
BENVOLIO
Tybalt, the kinsman of old Capulet,
Hath sent a letter to his father's house.
MERCUTIO
A challenge, on my life.
BENVOLIO
Romeo will answer it.
MERCUTIO
Any man that can write may answer a letter.
BENVOLIO
Nay, he will answer the letter's master, how he
dares, being dared.
MERCUTIO
Alas poor Romeo! he is already dead; stabbed with a
white wench's black eye; shot through the ear with a
love-song; the very pin of his heart cleft with the
blind bow-boy's butt-shaft: and is he a man to
encounter Tybalt?
BENVOLIO
Why, what is Tybalt?
MERCUTIO
More than prince of cats, I can tell you. O, he is
the courageous captain of compliments. He fights as
you sing prick-song, keeps time, distance, and
proportion; rests me his minim rest, one, two, and
the third in your bosom: the very butcher of a silk
button, a duellist, a duellist; a gentleman of the
very first house, of the first and second cause:
ah, the immortal passado! the punto reverso! the
hai!
BENVOLIO
The what?
MERCUTIO
The pox of such antic, lisping, affecting
fantasticoes; these new tuners of accents! 'By Jesu,
a very good blade! a very tall man! a very good
whore!' Why, is not this a lamentable thing,
grandsire, that we should be thus afflicted with
these strange flies, these fashion-mongers, these
perdona-mi's, who stand so much on the new form,
that they cannot at ease on the old bench? O, their
bones, their bones!
Enter ROMEO
BENVOLIO
Here comes Romeo, here comes Romeo.
MERCUTIO
Without his roe, like a dried herring: flesh, flesh,
how art thou fishified! Now is he for the numbers
that Petrarch flowed in: Laura to his lady was but a
kitchen-wench; marry, she had a better love to
be-rhyme her; Dido a dowdy; Cleopatra a gipsy;
Helen and Hero hildings and harlots; Thisbe a grey
eye or so, but not to the purpose. Signior
Romeo, bon jour! there's a French salutation
to your French slop. You gave us the counterfeit
fairly last night.
ROMEO
Good morrow to you both. What counterfeit did I give you?
MERCUTIO
The ship, sir, the slip; can you not conceive?
ROMEO
Pardon, good Mercutio, my business was great; and in
such a case as mine a man may strain courtesy.
MERCUTIO
That's as much as to say, such a case as yours
constrains a man to bow in the hams.
ROMEO
Meaning, to court'sy.
MERCUTIO
Thou hast most kindly hit it.
ROMEO
A most courteous exposition.
MERCUTIO
Nay, I am the very pink of courtesy.
ROMEO
Pink for flower.
MERCUTIO
Right.
ROMEO
Why, then is my pump well flowered.
MERCUTIO
Well said: follow me this jest now till thou hast
worn out thy pump, that when the single sole of it
is worn, the jest may remain after the wearing sole singular.
ROMEO
O single-soled jest, solely singular for the
singleness.
MERCUTIO
Come between us, good Benvolio; my wits faint.
ROMEO
Switch and spurs, switch and spurs; or I'll cry a match.
MERCUTIO
Nay, if thy wits run the wild-goose chase, I have
done, for thou hast more of the wild-goose in one of
thy wits than, I am sure, I have in my whole five:
was I with you there for the goose?
ROMEO
Thou wast never with me for any thing when thou wast
not there for the goose.
MERCUTIO
I will bite thee by the ear for that jest.
ROMEO
Nay, good goose, bite not.
MERCUTIO
Thy wit is a very bitter sweeting; it is a most
sharp sauce.
ROMEO
And is it not well served in to a sweet goose?
MERCUTIO
O here's a wit of cheveril, that stretches from an
inch narrow to an ell broad!
ROMEO
I stretch it out for that word 'broad;' which added
to the goose, proves thee far and wide a broad goose.
MERCUTIO
Why, is not this better now than groaning for love?
now art thou sociable, now art thou Romeo; now art
thou what thou art, by art as well as by nature:
for this drivelling love is like a great natural,
that runs lolling up and down to hide his bauble in a hole.
BENVOLIO
Stop there, stop there.
MERCUTIO
Thou desirest me to stop in my tale against the hair.
BENVOLIO
Thou wouldst else have made thy tale large.
MERCUTIO
O, thou art deceived; I would have made it short:
for I was come to the whole depth of my tale; and
meant, indeed, to occupy the argument no longer.
ROMEO
Here's goodly gear!
Enter Nurse and PETER
MERCUTIO
A sail, a sail!
BENVOLIO
Two, two; a shirt and a smock.
Nurse
Peter!
PETER
Anon!
Nurse
My fan, Peter.
MERCUTIO
Good Peter, to hide her face; for her fan's the
fairer face.
Nurse
God ye good morrow, gentlemen.
MERCUTIO
God ye good den, fair gentlewoman.
Nurse
Is it good den?
MERCUTIO
'Tis no less, I tell you, for the bawdy hand of the
dial is now upon the prick of noon.
Nurse
Out upon you! what a man are you!
ROMEO
One, gentlewoman, that God hath made for himself to
mar.
Nurse
By my troth, it is well said; 'for himself to mar,'
quoth a'? Gentlemen, can any of you tell me where I
may find the young Romeo?
ROMEO
I can tell you; but young Romeo will be older when
you have found him than he was when you sought him:
I am the youngest of that name, for fault of a worse.
Nurse
You say well.
MERCUTIO
Yea, is the worst well? very well took, i' faith;
wisely, wisely.
Nurse
if you be he, sir, I desire some confidence with
you.
BENVOLIO
She will indite him to some supper.
MERCUTIO
A bawd, a bawd, a bawd! so ho!
ROMEO
What hast thou found?
MERCUTIO
No hare, sir; unless a hare, sir, in a lenten pie,
that is something stale and hoar ere it be spent.
Sings
An old hare hoar,
And an old hare hoar,
Is very good meat in lent
But a hare that is hoar
Is too much for a score,
When it hoars ere it be spent.
Romeo, will you come to your father's? we'll
to dinner, thither.
ROMEO
I will follow you.
MERCUTIO
Farewell, ancient lady; farewell,
Singing
'lady, lady, lady.'
Exeunt MERCUTIO and BENVOLIO
Nurse
Marry, farewell! I pray you, sir, what saucy
merchant was this, that was so full of his ropery?
ROMEO
A gentleman, nurse, that loves to hear himself talk,
and will speak more in a minute than he will stand
to in a month.
Nurse
An a' speak any thing against me, I'll take him
down, an a' were lustier than he is, and twenty such
Jacks; and if I cannot, I'll find those that shall.
Scurvy knave! I am none of his flirt-gills; I am
none of his skains-mates. And thou must stand by
too, and suffer every knave to use me at his pleasure?
PETER
I saw no man use you a pleasure; if I had, my weapon
should quickly have been out, I warrant you: I dare
draw as soon as another man, if I see occasion in a
good quarrel, and the law on my side.
Nurse
Now, afore God, I am so vexed, that every part about
me quivers. Scurvy knave! Pray you, sir, a word:
and as I told you, my young lady bade me inquire you
out; what she bade me say, I will keep to myself:
but first let me tell ye, if ye should lead her into
a fool's paradise, as they say, it were a very gross
kind of behavior, as they say: for the gentlewoman
is young; and, therefore, if you should deal double
with her, truly it were an ill thing to be offered
to any gentlewoman, and very weak dealing.
ROMEO
Nurse, commend me to thy lady and mistress. I
protest unto thee--
Nurse
Good heart, and, i' faith, I will tell her as much:
Lord, Lord, she will be a joyful woman.
ROMEO
What wilt thou tell her, nurse? thou dost not mark me.
Nurse
I will tell her, sir, that you do protest; which, as
I take it, is a gentlemanlike offer.
ROMEO
Bid her devise
Some means to come to shrift this afternoon;
And there she shall at Friar Laurence' cell
Be shrived and married. Here is for thy pains.
Nurse
No truly sir; not a penny.
ROMEO
Go to; I say you shall.
Nurse
This afternoon, sir? well, she shall be there.
ROMEO
And stay, good nurse, behind the abbey wall:
Within this hour my man shall be with thee
And bring thee cords made like a tackled stair;
Which to the high top-gallant of my joy
Must be my convoy in the secret night.
Farewell; be trusty, and I'll quit thy pains:
Farewell; commend me to thy mistress.
Nurse
Now God in heaven bless thee! Hark you, sir.
ROMEO
What say'st thou, my dear nurse?
Nurse
Is your man secret? Did you ne'er hear say,
Two may keep counsel, putting one away?
ROMEO
I warrant thee, my man's as true as steel.
NURSE
Well, sir; my mistress is the sweetest lady--Lord,
Lord! when 'twas a little prating thing:--O, there
is a nobleman in town, one Paris, that would fain
lay knife aboard; but she, good soul, had as lief
see a toad, a very toad, as see him. I anger her
sometimes and tell her that Paris is the properer
man; but, I'll warrant you, when I say so, she looks
as pale as any clout in the versal world. Doth not
rosemary and Romeo begin both with a letter?
ROMEO
Ay, nurse; what of that? both with an R.
Nurse
Ah. mocker! that's the dog's name; R is for
the--No; I know it begins with some other
letter:--and she hath the prettiest sententious of
it, of you and rosemary, that it would do you good
to hear it.
ROMEO
Commend me to thy lady.
Nurse
Ay, a thousand times.
Exit Romeo
Peter!
PETER
Anon!
Nurse
Peter, take my fan, and go before and apace.
Exeunt
SCENE V. Capulet's orchard.
Enter JULIET
JULIET
The clock struck nine when I did send the nurse;
In half an hour she promised to return.
Perchance she cannot meet him: that's not so.
O, she is lame! love's heralds should be thoughts,
Which ten times faster glide than the sun's beams,
Driving back shadows over louring hills:
Therefore do nimble-pinion'd doves draw love,
And therefore hath the wind-swift Cupid wings.
Now is the sun upon the highmost hill
Of this day's journey, and from nine till twelve
Is three long hours, yet she is not come.
Had she affections and warm youthful blood,
She would be as swift in motion as a ball;
My words would bandy her to my sweet love,
And his to me:
But old folks, many feign as they were dead;
Unwieldy, slow, heavy and pale as lead.
O God, she comes!
Enter Nurse and PETER
O honey nurse, what news?
Hast thou met with him? Send thy man away.
Nurse
Peter, stay at the gate.
Exit PETER
JULIET
Now, good sweet nurse,--O Lord, why look'st thou sad?
Though news be sad, yet tell them merrily;
If good, thou shamest the music of sweet news
By playing it to me with so sour a face.
Nurse
I am a-weary, give me leave awhile:
Fie, how my bones ache! what a jaunt have I had!
JULIET
I would thou hadst my bones, and I thy news:
Nay, come, I pray thee, speak; good, good nurse, speak.
Nurse
Jesu, what haste? can you not stay awhile?
Do you not see that I am out of breath?
JULIET
How art thou out of breath, when thou hast breath
To say to me that thou art out of breath?
The excuse that thou dost make in this delay
Is longer than the tale thou dost excuse.
Is thy news good, or bad? answer to that;
Say either, and I'll stay the circumstance:
Let me be satisfied, is't good or bad?
Nurse
Well, you have made a simple choice; you know not
how to choose a man: Romeo! no, not he; though his
face be better than any man's, yet his leg excels
all men's; and for a hand, and a foot, and a body,
though they be not to be talked on, yet they are
past compare: he is not the flower of courtesy,
but, I'll warrant him, as gentle as a lamb. Go thy
ways, wench; serve God. What, have you dined at home?
JULIET
No, no: but all this did I know before.
What says he of our marriage? what of that?
Nurse
Lord, how my head aches! what a head have I!
It beats as it would fall in twenty pieces.
My back o' t' other side,--O, my back, my back!
Beshrew your heart for sending me about,
To catch my death with jaunting up and down!
JULIET
I' faith, I am sorry that thou art not well.
Sweet, sweet, sweet nurse, tell me, what says my love?
Nurse
Your love says, like an honest gentleman, and a
courteous, and a kind, and a handsome, and, I
warrant, a virtuous,--Where is your mother?
JULIET
Where is my mother! why, she is within;
Where should she be? How oddly thou repliest!
'Your love says, like an honest gentleman,
Where is your mother?'
Nurse
O God's lady dear!
Are you so hot? marry, come up, I trow;
Is this the poultice for my aching bones?
Henceforward do your messages yourself.
JULIET
Here's such a coil! come, what says Romeo?
Nurse
Have you got leave to go to shrift to-day?
JULIET
I have.
Nurse
Then hie you hence to Friar Laurence' cell;
There stays a husband to make you a wife:
Now comes the wanton blood up in your cheeks,
They'll be in scarlet straight at any news.
Hie you to church; I must another way,
To fetch a ladder, by the which your love
Must climb a bird's nest soon when it is dark:
I am the drudge and toil in your delight,
But you shall bear the burden soon at night.
Go; I'll to dinner: hie you to the cell.
JULIET
Hie to high fortune! Honest nurse, farewell.
Exeunt
SCENE VI. Friar Laurence's cell.
Enter FRIAR LAURENCE and ROMEO
FRIAR LAURENCE
So smile the heavens upon this holy act,
That after hours with sorrow chide us not!
ROMEO
Amen, amen! but come what sorrow can,
It cannot countervail the exchange of joy
That one short minute gives me in her sight:
Do thou but close our hands with holy words,
Then love-devouring death do what he dare;
It is enough I may but call her mine.
FRIAR LAURENCE
These violent delights have violent ends
And in their triumph die, like fire and powder,
Which as they kiss consume: the sweetest honey
Is loathsome in his own deliciousness
And in the taste confounds the appetite:
Therefore love moderately; long love doth so;
Too swift arrives as tardy as too slow.
Enter JULIET
Here comes the lady: O, so light a foot
Will ne'er wear out the everlasting flint:
A lover may bestride the gossamer
That idles in the wanton summer air,
And yet not fall; so light is vanity.
JULIET
Good even to my ghostly confessor.
FRIAR LAURENCE
Romeo shall thank thee, daughter, for us both.
JULIET
As much to him, else is his thanks too much.
ROMEO
Ah, Juliet, if the measure of thy joy
Be heap'd like mine and that thy skill be more
To blazon it, then sweeten with thy breath
This neighbour air, and let rich music's tongue
Unfold the imagined happiness that both
Receive in either by this dear encounter.
JULIET
Conceit, more rich in matter than in words,
Brags of his substance, not of ornament:
They are but beggars that can count their worth;
But my true love is grown to such excess
I cannot sum up sum of half my wealth.
FRIAR LAURENCE
Come, come with me, and we will make short work;
For, by your leaves, you shall not stay alone
Till holy church incorporate two in one.
Exeunt

View File

@@ -16,7 +16,6 @@ limitations under the License.
import asyncio
import logging
import os
from datetime import datetime
from time import time
from typing import Callable
@@ -25,7 +24,7 @@ from dotenv import load_dotenv
from neo4j import AsyncGraphDatabase
from graphiti_core.edges import EntityEdge, EpisodicEdge
from graphiti_core.llm_client import LLMClient, LLMConfig, OpenAIClient
from graphiti_core.llm_client import LLMClient, OpenAIClient
from graphiti_core.nodes import EntityNode, EpisodeType, EpisodicNode
from graphiti_core.search.search import SearchConfig, hybrid_search
from graphiti_core.search.search_utils import (
@@ -107,12 +106,7 @@ class Graphiti:
if llm_client:
self.llm_client = llm_client
else:
self.llm_client = OpenAIClient(
LLMConfig(
api_key=os.getenv('OPENAI_API_KEY', default=''),
model='gpt-4o-2024-08-06',
)
)
self.llm_client = OpenAIClient()
def close(self):
"""

View File

@@ -27,19 +27,21 @@ from .config import LLMConfig
logger = logging.getLogger(__name__)
DEFAULT_MODEL = 'claude-3-5-sonnet-20240620'
class AnthropicClient(LLMClient):
def __init__(self, config: LLMConfig | None = None):
def __init__(self, config: LLMConfig | None = None, cache: bool = False):
if config is None:
config = LLMConfig()
super().__init__(config, cache)
self.client = AsyncAnthropic(api_key=config.api_key)
self.model = config.model
def get_embedder(self) -> typing.Any:
openai_client = AsyncOpenAI()
return openai_client.embeddings
async def generate_response(self, messages: list[Message]) -> dict[str, typing.Any]:
async def _generate_response(self, messages: list[Message]) -> dict[str, typing.Any]:
system_message = messages[0]
user_messages = [{'role': m.role, 'content': m.content} for m in messages[1:]] + [
{'role': 'assistant', 'content': '{'}
@@ -49,9 +51,10 @@ class AnthropicClient(LLMClient):
result = await self.client.messages.create(
system='Only include JSON in the response. Do not include any additional text or explanation of the content.\n'
+ system_message.content,
max_tokens=4096,
max_tokens=self.max_tokens,
temperature=self.temperature,
messages=user_messages, # type: ignore
model='claude-3-5-sonnet-20240620',
model=self.model or DEFAULT_MODEL,
)
return json.loads('{' + result.content[0].text) # type: ignore

View File

@@ -14,22 +14,61 @@ See the License for the specific language governing permissions and
limitations under the License.
"""
import hashlib
import json
import logging
import typing
from abc import ABC, abstractmethod
from diskcache import Cache
from ..prompts.models import Message
from .config import LLMConfig
DEFAULT_TEMPERATURE = 0
DEFAULT_CACHE_DIR = './llm_cache'
logger = logging.getLogger(__name__)
class LLMClient(ABC):
@abstractmethod
def __init__(self, config: LLMConfig | None):
pass
def __init__(self, config: LLMConfig | None, cache: bool = False):
if config is None:
config = LLMConfig()
self.config = config
self.model = config.model
self.temperature = config.temperature
self.max_tokens = config.max_tokens
self.cache_enabled = cache
self.cache_dir = Cache(DEFAULT_CACHE_DIR) # Create a cache directory
@abstractmethod
def get_embedder(self) -> typing.Any:
pass
@abstractmethod
async def generate_response(self, messages: list[Message]) -> dict[str, typing.Any]:
async def _generate_response(self, messages: list[Message]) -> dict[str, typing.Any]:
pass
def _get_cache_key(self, messages: list[Message]) -> str:
# Create a unique cache key based on the messages and model
message_str = json.dumps([m.model_dump() for m in messages], sort_keys=True)
key_str = f'{self.model}:{message_str}'
return hashlib.md5(key_str.encode()).hexdigest()
async def generate_response(self, messages: list[Message]) -> dict[str, typing.Any]:
if self.cache_enabled:
cache_key = self._get_cache_key(messages)
cached_response = self.cache_dir.get(cache_key)
if cached_response is not None:
logger.debug(f'Cache hit for {cache_key}')
return cached_response
response = await self._generate_response(messages)
if self.cache_enabled:
self.cache_dir.set(cache_key, response)
return response

View File

@@ -15,6 +15,8 @@ limitations under the License.
"""
EMBEDDING_DIM = 1024
DEFAULT_MAX_TOKENS = 4096
DEFAULT_TEMPERATURE = 0
class LLMConfig:
@@ -29,8 +31,10 @@ class LLMConfig:
def __init__(
self,
api_key: str | None = None,
model: str = 'gpt-4o-mini',
base_url: str = 'https://api.openai.com/v1',
model: str | None = None,
base_url: str | None = None,
temperature: float = DEFAULT_TEMPERATURE,
max_tokens: int = DEFAULT_MAX_TOKENS,
):
"""
Initialize the LLMConfig with the provided parameters.
@@ -50,3 +54,5 @@ class LLMConfig:
self.base_url = base_url
self.api_key = api_key
self.model = model
self.temperature = temperature
self.max_tokens = max_tokens

View File

@@ -28,36 +28,37 @@ from .config import LLMConfig
logger = logging.getLogger(__name__)
DEFAULT_MODEL = 'llama-3.1-70b-versatile'
class GroqClient(LLMClient):
def __init__(self, config: LLMConfig | None = None):
def __init__(self, config: LLMConfig | None = None, cache: bool = False):
if config is None:
config = LLMConfig()
super().__init__(config, cache)
self.client = AsyncGroq(api_key=config.api_key)
self.model = config.model
def get_embedder(self) -> typing.Any:
openai_client = AsyncOpenAI()
return openai_client.embeddings
async def generate_response(self, messages: list[Message]) -> dict[str, typing.Any]:
openai_messages: list[ChatCompletionMessageParam] = []
async def _generate_response(self, messages: list[Message]) -> dict[str, typing.Any]:
msgs: list[ChatCompletionMessageParam] = []
for m in messages:
if m.role == 'user':
openai_messages.append({'role': 'user', 'content': m.content})
msgs.append({'role': 'user', 'content': m.content})
elif m.role == 'system':
openai_messages.append({'role': 'system', 'content': m.content})
msgs.append({'role': 'system', 'content': m.content})
try:
response = await self.client.chat.completions.create(
model='llama-3.1-70b-versatile',
messages=openai_messages,
temperature=0.0,
max_tokens=4096,
model=self.model or DEFAULT_MODEL,
messages=msgs,
temperature=self.temperature,
max_tokens=self.max_tokens,
response_format={'type': 'json_object'},
)
result = response.choices[0].message.content or ''
return json.loads(result)
except Exception as e:
print(openai_messages)
logger.error(f'Error in generating LLM response: {e}')
raise

View File

@@ -27,18 +27,22 @@ from .config import LLMConfig
logger = logging.getLogger(__name__)
DEFAULT_MODEL = 'gpt-4o-2024-08-06'
class OpenAIClient(LLMClient):
def __init__(self, config: LLMConfig | None = None):
def __init__(self, config: LLMConfig | None = None, cache: bool = False):
if config is None:
config = LLMConfig()
super().__init__(config, cache)
self.client = AsyncOpenAI(api_key=config.api_key, base_url=config.base_url)
self.model = config.model
def get_embedder(self) -> typing.Any:
return self.client.embeddings
async def generate_response(self, messages: list[Message]) -> dict[str, typing.Any]:
async def _generate_response(self, messages: list[Message]) -> dict[str, typing.Any]:
openai_messages: list[ChatCompletionMessageParam] = []
for m in messages:
if m.role == 'user':
@@ -47,10 +51,10 @@ class OpenAIClient(LLMClient):
openai_messages.append({'role': 'system', 'content': m.content})
try:
response = await self.client.chat.completions.create(
model=self.model,
model=self.model or DEFAULT_MODEL,
messages=openai_messages,
temperature=0,
max_tokens=4096,
temperature=self.temperature,
max_tokens=self.max_tokens,
response_format={'type': 'json_object'},
)
result = response.choices[0].message.content or ''

View File

@@ -87,7 +87,19 @@ async def retrieve_episodes(
reference_time: datetime,
last_n: int = EPISODE_WINDOW_LEN,
) -> list[EpisodicNode]:
"""Retrieve the last n episodic nodes from the graph"""
"""
Retrieve the last n episodic nodes from the graph.
Args:
driver (AsyncDriver): The Neo4j driver instance.
reference_time (datetime): The reference time to filter episodes. Only episodes with a valid_at timestamp
less than or equal to this reference_time will be retrieved. This allows for
querying the graph's state at a specific point in time.
last_n (int, optional): The number of most recent episodes to retrieve, relative to the reference_time.
Returns:
list[EpisodicNode]: A list of EpisodicNode objects representing the retrieved episodes.
"""
result = await driver.execute_query(
"""
MATCH (e:Episodic) WHERE e.valid_at <= $reference_time

16
poetry.lock generated
View File

@@ -530,6 +530,20 @@ files = [
{file = "diskcache-5.6.3.tar.gz", hash = "sha256:2c3a3fa2743d8535d832ec61c2054a1641f41775aa7c556758a109941e33e4fc"},
]
[[package]]
name = "diskcache-stubs"
version = "5.6.3.6.20240818"
description = "diskcache stubs"
optional = false
python-versions = ">=3"
files = [
{file = "diskcache_stubs-5.6.3.6.20240818-py3-none-any.whl", hash = "sha256:e1db90940b344140730976abe79f57f5b43ca296cbb43fa95da0c69b12d5de4f"},
{file = "diskcache_stubs-5.6.3.6.20240818.tar.gz", hash = "sha256:b6eb43899e906b3167a20ac09a9a226f30267a306a96542ea720ebbfc3282796"},
]
[package.dependencies]
typing-extensions = ">=4.4.0"
[[package]]
name = "distro"
version = "1.9.0"
@@ -3729,4 +3743,4 @@ test = ["websockets"]
[metadata]
lock-version = "2.0"
python-versions = "^3.10"
content-hash = "7a39a71738b144a77525b8d449a6d624856b1f20a4b6e3d0694d41e68bafe610"
content-hash = "5b90bb6d58d36a2553f5410c418b179aa1c86b55078567c33aaa6fddf6a8c6c6"

View File

@@ -37,6 +37,7 @@ mypy = "^1.11.1"
groq = "^0.9.0"
ipykernel = "^6.29.5"
jupyterlab = "^4.2.4"
diskcache-stubs = "^5.6.3.6.20240818"
[build-system]
requires = ["poetry-core"]